2012-09-23 177 views
2

在我的gridview中,所有的单元格最初呈现为矩形,但第二次查看它们是方形的。android gridview单元格大小

我有逻辑,使他们多,但我希望他们方形它们加载

首次

我的问题是,我不明白为什么的意见是最初的矩形,或任何特定的比例在所有!

我的XML文件都设置为填补父母,我甚至把一个正方形图像占位符,企图迫使观点被渲染方

有一些关于GridView的我应该知道的?

回答

0

答案是到GridView小区内致以ImageView的,和@OverrideonMeasure方法和动态地生成平方比例存在

0
  1. 创建定制阵列适配器。(JAVA)

见(Showing graphical instead of strings in an imagelist with title

定制
  • 阵列adpater xml文件(小区)写的东西像这样:

    <?xml version="1.0" encoding="utf-8"?> 
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="50dp" 
        android:layout_height="50dp" > 
        <ImageView 
         android:id="@+id/iv_caarow" 
         android:src="@drawable/icon" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" /> 
        </RelativeLayout> 
    
  • 的droid:layout_width =“50dp”,你可以像这样设置单元格大小。