android中的Gridview列表项
我已经将gridview设置为两列,值会正确显示,但是当显示文本时,如果文本转到第二行,则第1列的大小较小,第2列的大小较大。我不知道为什么会这样?我已经把一切都安排好了 这是我想说的一个想法: 你注意到红色的圆圈了吗。第3行第1列比第3行第2列小为什么?如何使所有列保持不变 以下是我的gridview.xml:android中的Gridview列表项,android,xml,gridview,Android,Xml,Gridview,我已经将gridview设置为两列,值会正确显示,但是当显示文本时,如果文本转到第二行,则第1列的大小较小,第2列的大小较大。我不知道为什么会这样?我已经把一切都安排好了 这是我想说的一个想法: 你注意到红色的圆圈了吗。第3行第1列比第3行第2列小为什么?如何使所有列保持不变 以下是我的gridview.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schem
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:orientation="vertical"
tools:ignore="ContentDescription,RtlHardcoded,NestedWeights" >
<TextView
android:id="@+id/noData"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/nocontantdata"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="italic"
android:visibility="gone" />
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:horizontalSpacing="2dp"
android:numColumns="2"
android:scrollbars="vertical"
android:verticalSpacing="2dp"
android:visibility="visible" >
</GridView>
<ImageView
android:id="@+id/imagefooter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/footer_band"
tools:ignore="ObsoleteLayoutParam" />
</RelativeLayout>
还有我的itemsRow.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/itemsLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/layoutbackground"
android:gravity="center">
<ImageView
android:id="@+id/profileImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:background="@drawable/friends"
android:paddingBottom="5dp"
android:paddingTop="5dp" />
<TextView
android:id="@+id/profileText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/profileImage"
android:gravity="center"
android:paddingTop="5dp"
android:textColor="@color/blackText"
android:text="@string/profile_text"
android:textSize="16sp" />
</RelativeLayout>
这里可能出了什么问题
谢谢 这样做:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/itemsLayout"
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="vertical"
android:background="@color/layoutbackground"
android:gravity="center">
<ImageView
android:id="@+id/profileImage"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:background="@drawable/friends"
android:paddingBottom="5dp"
android:paddingTop="5dp" />
<TextView
android:id="@+id/profileText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:paddingTop="5dp"
android:textColor="@color/blackText"
android:text="@string/profile_text"
android:textSize="16sp" />
</LinearLayout>
如果您只想保持项目大小不变,则只能显示一行文本。将参数maxlines=1更改/添加到textView中,这将使它们保持较小的大小。您的项目的相对布局高度应设置为包裹内容,不确定这是否会造成差异。在itemsRow.xml中提供固定的相对布局高度假设为“150dp”,如果我这样做,则在不同分辨率的手机上不会出现问题。我的意思是,它会是一样的吗?是的,你只是固定了相对物的高度,并且对每个设备都是一样的嘿!我从match_parent改为150dp,也尝试了200dp,但仍然一样。尺寸没有变大…线性布局是包裹还是150dp都没有区别。是文本视图造成了不同:)是的,我只是给你一个例子。。有多种方法可以解决它:)