我正在通过GridView显示来自RESTFul web服务的一些图像。最大行数是4,如何计算图像的最佳宽度取决于屏幕可以是竖屏模式还是横屏模式?或者我应该使用一些常量,取决于屏幕密度?
发布于 2015-11-06 00:09:36
具有GridView属性的PLay,特别是android:numColumns="auto_fit" and android:stretchMode.,例如:
<GridView
android:id="@+id/myGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:columnWidth="60dp"
android:stretchMode="columnWidth"
android:gravity="center"
/>发布于 2015-11-06 00:23:58
我会在运行时创建/更新网格参数,就在下载图像之前。
有关在运行时获取视图宽度/高度的信息,请参阅this post。
顺便说一句,我强烈推荐ImageDownloader来下载和显示图像-它可以在加载缩放图像时使用缓存和节省内存。
https://stackoverflow.com/questions/33548961
复制相似问题