问题描述
我有纵向和横向模式的活动。
该活动包含列表视图。这个列表视图有一个页脚,我加入编程方式是这样的:
查看页脚= LayoutInflater.from(本).inflate(R.layout.footer_button,
空值);
footer.setPadding(0,0,0,0);
lv_details.addFooterView(页脚);
和页脚 footer_button.xml
的布局是:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直><按钮的android:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:ID =@ + ID / B_OK
机器人:文字=@字符串/ B_OK
机器人:文字颜色=#FFFFFF
机器人:背景=@绘制/ bg_selector/>
< / LinearLayout中>
这与人像模式完美的作品。
图像时页脚(OK键)是正确的
现在,当我去到风景模式时,我得到了这个问题。
这里是页脚成为
我进入数字体系观众,我想我找到了错误,看看这个照片,请
如你所见,宽度匹配父
不是填写父母,即使我已经使用
填写父
在我的布局。
如何解决吗?
code后,有人问到
适配器=新AdapterFoodProfile(这一点,ALIST);
查看标题= LayoutInflater.from(本).inflate(
R.layout.customer_profile_header,NULL);
tv_edit =(TextView的)头
.findViewById(R.id.tv_customer_profile_header_edit);
tv_edit.setOnClickListener(本);
lv_details.addHeaderView(头);
查看页脚= LayoutInflater.from(本).inflate(R.layout.footer_button,
空值);
footer.setPadding(0,0,0,0);
B_OK =(按钮)footer.findViewById(R.id.b_ok);
b_ok.setOnClickListener(本);
lv_details.addFooterView(页脚);
lv_details.setAdapter(适配器);
如果这甚至部分地解决了这个问题,像你一样 - 在的ListView
已设置为的android:layout_width =FILL_PARENT
。如果发生了另一个问题是将与这一个间接
I have an activity with portrait and landscape mode.
the activity contains listview. this listview has a footer, which I added programmatically like this:
View footer = LayoutInflater.from(this).inflate(R.layout.footer_button,
null);
footer.setPadding(0, 0, 0, 0);
lv_details.addFooterView(footer);
and the layout for the footer footer_button.xml
is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/b_ok"
android:text="@string/b_ok"
android:textColor="#FFFFFF"
android:background="@drawable/bg_selector"/>
</LinearLayout>
that works perfectly with the portrait mode. image when the footer (ok button) is correct
Now when I go to landscape mode, I got the problem.here is what the footer became
I go into the Hierachy viewer and I think I found the error, look at this photo pleaseas you see, the width is Match parent
not fill parent
even though I have used fill parent
in my layout.
what is the solution please?
Code after someone asked to
adapter = new AdapterFoodProfile(this, aList);
View header = LayoutInflater.from(this).inflate(
R.layout.customer_profile_header, null);
tv_edit = (TextView) header
.findViewById(R.id.tv_customer_profile_header_edit);
tv_edit.setOnClickListener(this);
lv_details.addHeaderView(header);
View footer = LayoutInflater.from(this).inflate(R.layout.footer_button,
null);
footer.setPadding(0, 0, 0, 0);
b_ok = (Button) footer.findViewById(R.id.b_ok);
b_ok.setOnClickListener(this);
lv_details.addFooterView(footer);
lv_details.setAdapter(adapter);
If this fixes the problem, even partially, as you did - the ListView
has been set to android:layout_width="fill_parent"
. If another problem occurs it will be related to this one indirectly.
这篇关于Android的ListView的页脚宽度改为本身匹配父的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!