Android的GridView的项目重新调整 [英] Android GridView Items Resizing

查看:123
本文介绍了Android的GridView的项目重新调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个GridView来显示饲料。如果条目具有用于它的背景图像,该图像被从该设备或服务器加载。我的问题是加载图像时,GridView的项目扩展以适应图像。我希望图像按比例缩小以适合框。

I using a GridView to display a feed. If the entry has a background image for it, the image gets loaded from the device or the server. My problem is that when an image is loaded, the gridview's item expands to accomodate the image. I want the image to scale down to fit the box.

我一直在使用各种scaletypes一个的ImageView和使用视图的背景试过。似乎没有任何工作。任何想法?

I have tried using an ImageView with various scaletypes and using the view's background. Nothing seems to work. Any ideas?

推荐答案

我找到的答案是,当我的充气XML是我用的是:

The answer I found was that when I was inflating the XML is I was using:

LayoutInflater.from(context).inflate(R.layout.item, null)

而不是

LayoutInflater.from(context).inflate(R.layout.item, container, false);

如果您使用的第一,放大视图和容器不沟通,所以layout_XXX属性被忽略的看法。

If you use the first, the inflated view and the container don't communicate, so the "layout_XXX" attributes for the view are ignored.

这篇关于Android的GridView的项目重新调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆