在我的应用程序中,我有一个包含LinearLayout--> TopGridView--> Middleset of views which should be aligned to the bottom的布局。

1. GridView内容不多时的布局

2.增加网格视图内容时的布局

3.布局,当Gridview内容很大时应如何显示


 


目前,当网格视图中的内容增加而导致较低级别的内容在屏幕中不可见时,我的Gridview正在扩展。

我不想为网格视图分配特定的高度,因为它在具有不同尺寸的屏幕中看起来很奇怪。

Is there any way that the gridview expands only upto the bottom views?我的父布局是LinearLayout。我已经尝试了相对布局,但是它不起作用。

最佳答案

我也面临同样的问题,并通过如下修改相应的xml找到了解决方案:


使用RelativeLayout作为父布局。
将标题内容放在RelativeLayout
对动态更改的GridView使用ScrollView
将页脚布局放在ScrollView之后


如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" >
 <TextView
    android:id="@+id/txtTextView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>
  <ScrollView
    android:id="@+id/scro1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/txtTextView" >
  <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
  <GridView
    android:id="@+id/scro1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>
  </LinearLayout>
  </ScrollView>
  </RelativeLayout>


android:layout_below中的ScrollView属性有所不同。

10-07 12:05
查看更多