【发布时间】:2014-01-27 09:47:38
【问题描述】:
我的应用程序的 LinearLayout 部分已完成。我现在正在使用RelativeLayout 在屏幕/活动的顶部添加一个小条,但我似乎将它与下图中我想要的方式相反。
棕褐色的线性布局在顶部的一个小栏中可见,这就是我希望白色的 RelativeLayout 和 LinearLayout 应该使用 RelativeLayout 占用的空白空间。我很困惑如何:
更改 RelativeLayout,使其高度仅与顶部的栏一样高 (50dp)
LinearLayout 开始向下 50dp,使其顶部与 RelativeLayout 的底部相接
仅包含 LinearLayout 的原始 XML 文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#F8FBBF" >
<ExpandableListView
android:id="@+id/lvExp"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:cacheColorHint="#00000000"/>
</LinearLayout>
RelativeLayout 包含 LinearLayout 的修改后的 XML 文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="50dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#F8FBBF" >
<ExpandableListView
android:id="@+id/lvExp"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:cacheColorHint="#00000000"/>
</LinearLayout>
</RelativeLayout>
感谢您提前提供的任何帮助。
【问题讨论】:
标签: android android-linearlayout android-relativelayout