【问题标题】:Relative Layout component at the bottom using <include > issue底部的相对布局组件使用 <include> 问题
【发布时间】:2012-01-30 07:30:22
【问题描述】:

我需要设计与Adding component at the bottom 中定义的几乎相似的结构

我遵循了该线程中给出的答案。但是我的问题是,如果我使用标签导入另一个在LinearLayout 中有一些组件的xml,并且如果我尝试在我的xml 中添加具有RelativeLayout 的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>

【问题讨论】:

  • 也请分享 options_bar 布局。我认为 option_bar 高度存在问题(可能是“fill_parent”)。
  • @Arslan:非常感谢。它解决了我的问题。使用“match_parent”而不是“fill_parent”。

标签: android android-linearlayout android-relativelayout


【解决方案1】:

一切看起来都很好。请第一次检查您option_bar.xml。我认为问题在于它的高度。可能是你设置了option_bar.xml

android:layout_height = "fill_parent"

如果是这样,请将其更改为“wrap_content”或“match_parent”。

【讨论】:

  • 已标记。但我认为问题是别的。因为,我已经设置了android:layout_width="fill_parent"android:layout_height="fill_parent",但现在仍然可以正常工作。
猜你喜欢
  • 2013-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-29
  • 1970-01-01
相关资源
最近更新 更多