布局规范w / r宽度和高度规则的优先级是什么?

时间:2014-02-06 22:51:47

标签: android android-layout relativelayout

使用RelativeLayouts,我的布局是

layout_alignParentLeft="true"
layout_alignParentRight="true"
layout_below="id/----"
layout_above="id/++++"
width="fill_parent"

我应该设置多高?

我很想使用fill_parent,但视图小于父级的高度。

如果我使用wrap_content,我稍后会遇到问题,因为我在计算中使用了视图的宽度

我正在寻找这样的东西(看星星):

---------------
***************
***************
***************
***************
+++++++++++++++

1 个答案:

答案 0 :(得分:0)

我正在使用它来进行地图布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"       
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


<LinearLayout
        android:id="@+id/layout_status_lights"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="@color/Red"
        android:orientation="horizontal"
        android:layout_alignParentTop="true"        
        android:paddingBottom="5dp" >

    </LinearLayout>           


     <com.google.android.gms.maps.MapView       
        android:layout_width="match_parent"
        android:layout_below="@+id/layout_status_lights"
        android:layout_above="@+id/layout_data"
        android:layout_height="match_parent"        
        android:id="@+id/mapa_destino" />

    <LinearLayout
        android:id="@+id/layout_data"
        android:layout_widt="match_parent"
        android:layout_height="30dp"
        android:orientation="horizontal"
        android:background="@color/Red"
        android:layout_alignParentBottom="true"
        android:padding="6dp"                      
        ">

     </LinearLayout>
</RelativeLayout>

就是这样:

enter image description here