android–ListView页脚宽度

android–ListView页脚宽度,第1张

概述我的列表视图的页脚有问题(我无法居中页脚).我正在使用页脚作为无穷无尽的列表.我遇到的问题是页脚未拉伸以匹配列表宽度(而是以某种方式使用wrap_content).这是页脚布局:<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk

我的列表视图的页脚有问题(我无法居中页脚).

我正在使用页脚作为无穷无尽的列表.

我遇到的问题是页脚未拉伸以匹配列表宽度(而是以某种方式使用wrap_content).

这是页脚布局:

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:ID="@+ID/footer_layout"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_gravity="center_horizontal"    androID:gravity="center"    androID:padding="10dp" >    <Progressbar        androID:ID="@+ID/progressbar"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_gravity="center_vertical" />    <TextVIEw        androID:ID="@+ID/textVIEw"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:padding="5dp"        androID:text="Loading more..." /></linearLayout>

这就是我将页脚添加到列表视图的方式:

VIEw footerVIEw;...     // Get the custom layout for footer        footerVIEw = getActivity().getLayoutInflater().                inflate(R.layout.List_footer_load_more, getListVIEw(), false);        linearLayout footerVIEwLayout = (linearLayout) footerVIEw.findVIEwByID(R.ID.footer_layout);        // Adding custom vIEw to ListVIEw at footer        getListVIEw().addFooterVIEw(footerVIEwLayout, null, false);

这就是最终结果的样子:
(我无法在stackoverflow上发布图像,但这里是图像的外部链接)
http://s21.postimg.org/3zkd7pic7/listview_footer_problem.png

我尝试了所有内容以使页脚居中,但没有任何效果.我希望有人可以帮助我,因为这让我感到有些压力.

谢谢.

解决方法:

将页脚布局(R.layout.List_footer_load_more)更改为:

<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:ID="@+ID/footer_layout"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:gravity="center_horizontal" >    <linearLayout        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content" >        <Progressbar            androID:ID="@+ID/progressbar"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_gravity="center_vertical" />        <TextVIEw            androID:ID="@+ID/textVIEw"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:padding="5dp"            androID:layout_gravity="center_vertical"            androID:text="Loading more..." />    </linearLayout></relativeLayout>  

将您的代码更改为:

VIEw footerVIEw;...     // Get the custom layout for footerfooterVIEw = getActivity().getLayoutInflater().            inflate(R.layout.List_footer_load_more, null);relativeLayout footerVIEwLayout = (relativeLayout) footerVIEw.findVIEwByID(R.ID.footer_layout);    // Adding custom vIEw to ListVIEw at footer    getListVIEw().addFooterVIEw(footerVIEwLayout, null, false);
总结

以上是内存溢出为你收集整理的android – ListView页脚宽度全部内容,希望文章能够帮你解决android – ListView页脚宽度所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1119002.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存