我正试图通过使用include来在每个活动的底部放置一个TextView ...我的代码在下面...我不知道为什么,但它仍然在顶部...虽然它工作正常对于TextView。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#E0E0E0"
android:orientation="vertical" />
<include
android:layout_alignParentBottom="true"
android:id="@+id/footer"
layout="@layout/footer" />
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:text="Hello"
android:textColor="#000000"
android:textSize="15dp" />
答案 0 :(得分:0)
¿也许您使用的是LinearLayout而不是RelativeLayout?后者没有android:orientation属性。我们没有看到父XML节点,所以只是一个猜测
此外,您需要将包含在底部并在其上方放置TextView
<TextView
...
android:layout_above="@id/footer" />
现在你正在重叠两个观点
另一个建议是使用FragmentActivity和Fragment来处理页脚,但这不属于这个问题的范围。
答案 1 :(得分:0)
在与父布局相同的xml代码中使用RelativeLayout。
答案 2 :(得分:0)
我得到了解决方案....我不得不在另一个孩子的相对布局中添加include ...这就是我所做的..
enter code here
RelativeLayout的 机器人:layout_width = “FILL_PARENT” android:layout_height =“wrap_content”&gt;
<include
android:id="@+id/footer"
android:layout_alignParentBottom="true"
layout="@layout/footer" />
</RelativeLayout>
但是......对于textview,它可以直接使用而不使用其他子布局...那么为什么你需要为包含这样做?????:|
答案 3 :(得分:0)
我检查了你的代码。它在第一篇文章中发布的工作正常。
请注意,当您使用layout
标记时,Eclipse'图形布局将不会绘制您包含的子xml布局(在您的情况下为footer.xml
)。
同时,如果您在实际设备或模拟器上运行相同的代码,您将获得所需的页脚。
注意:您可能希望从android:layout_alignParentBottom="true"
移除textView1
,因为当前textView1
和footer
布局重叠。