[英]Android RelativeLayout above Fragment
我正在尝试在片段上方显示RelativeLayout,但没有成功。
这是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#5C5A59"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="5dp" >
</RelativeLayout>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center|bottom"
android:background="#5C5A59"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<TextView
android:id="@+id/lbl_altitude"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/lbl_altitude"
android:textColor="#00FFFF"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</LinearLayout>
使用此代码,Fragment总是占据整个屏幕的尺寸,而我的RelativeLayout不在isnt显示屏上。
先感谢您。
尝试使用layout_weight
属性
您可以阅读本指南: 线性布局
如果您使用的是线性布局,则必须设置权重,这将根据百分比设置屏幕,例如,如果将权重总和1赋予父级,然后首先将布局权重0.2赋予布局,而将fragage赋予0.8这意味着您的布局获得了20%的屏幕,其他碎片获得了80%
因此,我认为您想使用“相对”布局作为父级,并在父级顶部设置第一个子级,然后将下面的部分设置为相对布局。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.