【问题标题】:How to reduce footer view of a list view如何减少列表视图的页脚视图
【发布时间】:2013-08-26 00:24:44
【问题描述】:

我有一个列表,我正在向它添加一个页脚视图。但是页脚视图的高度始终是固定的。我想要大约一半大小的东西,但页脚视图的大小根本没有改变。我在它的 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>

【问题讨论】:

  • 你需要设置那个膨胀的页脚视图布局的高度
  • 您用作页脚的视图是什么?一些代码会很好......
  • 我尝试设置高度,但它不起作用。
  • schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="2dp" android:orientation="vertical" android:background="#ff0000" >
  • 将您的代码作为编辑放入您的答案中!它不可读

标签: android list height footer


【解决方案1】:

最后以下工作....... :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>

【讨论】:

    【解决方案2】:

    在运行时在列表中添加FooterView并相应地更改它的LayoutParams

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

        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);
    

    【讨论】:

    • 我有一些布局而不是按钮.. 但即使是参数也不起作用:(
    • @SP Code Edited, try to Inflate code at runtime to set it's width, height Accordinigly.
    • @strike : 运行时不需要更改参数,更改 Xml 应该可以。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-26
    • 1970-01-01
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多