我面临一个问题,即根据孩子的身高制作ListView的行高。我试过How to set different heights for each row in a ListView?,但它不适合我。这是我的ListView行XML。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/category_name_text_view_height"
android:text="New Text"
android:id="@+id/moreCategoryName"
android:background="@drawable/category_name_background"
android:textColor="@android:color/white"
android:paddingLeft="@dimen/category_name_padding_left"
android:gravity="center_vertical"
android:textSize="@dimen/category_content_name_text_size" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/zero_dimen"
android:layout_marginTop="@dimen/more_content_layout_margin_top_bottom"
android:layout_marginBottom="@dimen/more_content_layout_margin_top_bottom"
android:id="@+id/moreGridLayout"
android:gravity="center_vertical"
android:layout_weight="1">
<ImageView
android:layout_width="@dimen/zero_dimen"
android:layout_height="wrap_content"
android:id="@+id/moreImageBackWard"
android:layout_weight="1"
android:src="@drawable/ic_backward"
android:padding="@dimen/more_content_indicator_padding_all" />
<GridView
android:layout_width="@dimen/zero_dimen"
android:layout_height="wrap_content"
android:id="@+id/moreContentGrid"
android:layout_weight="13"
android:verticalSpacing="@dimen/fav_grid_vertical_spacing"
android:numColumns="auto_fit"
android:columnWidth="@dimen/search_grid_column_width" />
<ImageView
android:layout_width="@dimen/zero_dimen"
android:layout_height="wrap_content"
android:id="@+id/moreImageForward"
android:layout_weight="1"
android:src="@drawable/ic_forward"
android:padding="@dimen/more_content_indicator_padding_all" />
</LinearLayout>
</LinearLayout>
如果我设置contentGridView
的某个高度,我现在可以实现此目的。但是当我将layout:height
设置为wrap_content
contentGridView
时,它只会显示一行,从而导致ListView行的高度不变。
由于