How can I stretch the cells of the GridView vertically?

邮差的信 提交于 2019-12-08 02:12:37

问题


I have this GridView:

<GridView     android:id="@+id/gridEtebarSanji"
              android:layout_width="match_parent"
              android:layout_height="480dp"
              android:background="@color/black"
              android:gravity="center"
              android:horizontalSpacing="2dp"
              android:isScrollContainer="false"
              android:numColumns="3"
              android:stretchMode="columnWidth"
              android:verticalSpacing="2dp" >

  </GridView>

And this layout to be used for the item inside of it:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal" >

    <TextView
        android:id="@+id/tvText"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        android:singleLine="false"
        android:text="TextView"
        android:textSize="16dip" />

</LinearLayout>

And the result:

I want to stretch single line cells to be as long as multi-line cells. How can I do that?

I have set android:layout_height="match_parent" for textViews but it does not affect.


回答1:


Set your TextView to display 2 lines:

<TextView
        android:id="@+id/tvText"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        android:lines="2"
        android:text="TextView"
        android:textSize="16dip" />


来源:https://stackoverflow.com/questions/11843192/how-can-i-stretch-the-cells-of-the-gridview-vertically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!