我正在使用GridView在相对布局。我希望GridView显示为 ,并根据需要显示所有行。但是,设置时我只看到 一行(layout_width = MATCH_PARENT和) layout_height = WRAP_CONTENT。如果我将layout_height设置为 等于多行的大小,那么我确实会看到这些行。Gridview只返回一行
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
>
<RelativeLayout
android:id="@+id/layout_month"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/textv_month_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:gravity="center_horizontal|center_horizontal"
android:textColor="#ffffff"
android:textSize="7dp" />
<ImageView
android:id="@+id/top_bar"
android:layout_width="fill_parent"
android:layout_height="15dp"
android:layout_below="@+id/textv_month_name"
android:background="@drawable/calendar_top_small"
android:clickable="false" />
<GridView
android:id="@+id/gridv_inner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/top_bar"
android:layout_gravity="center"
android:clickable="false"
android:gravity="center"
android:numColumns="7"
android:stretchMode="columnWidth"
>
</GridView>
<Button
android:id="@+id/monthBtn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent" />
</RelativeLayout>
</RelativeLayout>
任何帮助将很可观
发表您的XML文件和代码也。 – Piyush
https://groups.google.com/forum/#!topic/android-developers/P5zlnvpbQLU –