如何减少列表视图的页脚视图

时间:2013-08-23 04:10:52

标签: android list height footer

我有一个列表,我正在添加一个页脚视图。但页脚视图的高度始终是固定的。我想要大约一半大小的东西,但是页脚视图的大小根本没有变化。我在其xml布局文件中尝试了许多组合。请帮忙。

   <?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="wrap_content"
                android:orientation="vertical"
                android:background="#ff0000" 
                >

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Footer...." />

            </LinearLayout>

2 个答案:

答案 0 :(得分:2)

最后,以下工作..........:P:P

            <?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="wrap_content"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="fill_parent"
                    android:layout_height="@dimen/bubble_bottom_indent" />

            </LinearLayout>

答案 1 :(得分:0)

在运行时在列表中添加页脚视图并相应地更改其LayoutParams

    Button addButton = new Button(this);
    addButton.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    lv.addFooterView(addButton, null, true);

OR

    View view = inflater.inflate(R.layout.category, container, false);
    View footerView = inflater.inflate(R.layout.footer_category, null);
     LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, getResources.getDimension(R.dimen.height));
     footerView.setLayoutParams(lp)
    listview.addFooterView(footerView);