1

我想显示一个片段上面的RelativeLayout没有成功。Android的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> 

使用此代码的片段总是需要在屏幕的整体大小和我的RelativeLayout上述心不是显示。

预先感谢您。

回答

0

尝试使用layout_weight财产

您可以阅读本指南:如果您使用的是线性布局Linear Layout

0

,那么你必须按百分比,例如,如果设置的权重,这将设置你的屏幕你给权重1给父母,然后你首先给你的布局权重0.2为你的布局昂0.8,这意味着你的布局获得20%的屏幕和其他的Fragement获得80%

所以我想你想用相对布局作为你的父母和集合第一个孩子对齐父母的顶部,并将下面的分割设置为相对布局。

+0

非常感谢你,使用布局权重一切都完美! – user2802154 2014-09-04 14:39:12