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