底部的相对布局组件使用问题
我需要设计与 在底部添加组件 中定义的几乎类似的结构,
我遵循该线程中给出的答案。但我的问题是,如果我使用标签导入另一个在 LinearLayout
中有一些组件的 xml,并且如果我尝试在具有 RelativeLayout
的 xml 中添加该 xml,则该组件使用标签导入的内容不会到达屏幕底部。但奇怪的是,如果我用同一个 xml 中的某个组件(例如按钮)替换导入的组件,该按钮就会转到底部。请帮我。
这是代码-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- Title Bar -->
<include
android:layout_alignParentTop="true"
android:id="@+id/title_bar"
layout="@layout/title_bar"
android:layout_marginBottom="1dip"/>
<!-- Options Bar -->
<include
android:layout_alignParentBottom="true"
android:id="@+id/options_bar"
layout="@layout/options_bar"
/>
<!--
<Button android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"/>
-->
</RelativeLayout>
I need to design almost similar structure as defined in Adding component at the bottom
I followed the answer given in that thread. But my problem is, if I use tag to import another xml which has some components in LinearLayout
and if I try to add that xml in my xml having RelativeLayout
, the component which was imported using tag won't go to the bottom of the screen. But strangely, if I replace that imported component with some component like a button in that same xml, the button goes to the bottom. Please help me.
Here's the code-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- Title Bar -->
<include
android:layout_alignParentTop="true"
android:id="@+id/title_bar"
layout="@layout/title_bar"
android:layout_marginBottom="1dip"/>
<!-- Options Bar -->
<include
android:layout_alignParentBottom="true"
android:id="@+id/options_bar"
layout="@layout/options_bar"
/>
<!--
<Button android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"/>
-->
</RelativeLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每件事看起来都很好。请首先检查
option_bar.xml
。我认为问题在于它的高度。可能您已经设置了option_bar.xml
android:layout_height = "fill_parent"
如果是这样,请将其更改为“wrap_content”或“match_parent”。
Every thing look fine. Please 1st check you
option_bar.xml
. I am thinking the issue is its height. May be you have set theoption_bar.xml
android:layout_height = "fill_parent"
If so then please change it to "wrap_content" or "match_parent".