底部的相对布局组件使用问题

发布于 2024-12-31 23:26:49 字数 1246 浏览 4 评论 0原文

我需要设计与 在底部添加组件 中定义的几乎类似的结构,

我遵循该线程中给出的答案。但我的问题是,如果我使用标签导入另一个在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里寻她 2025-01-07 23:26:49

每件事看起来都很好。请首先检查 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 the option_bar.xml

android:layout_height = "fill_parent"

If so then please change it to "wrap_content" or "match_parent".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文