2014-04-08 69 views
-1

我想創建登錄佈局類似如下.. 使用權重屬性..如何使用重量的Android設備創建獨立的佈局屬性

enter image description here

它應該是獨立於設備.. 意味着在所有的Android設備應該看起來相同

+2

看起來好像9個補丁很方便。和背景(下半部分)。真的,我認爲這可以用一個(更輕)RelativeLayout來完成,沒有權重 –

+0

你試試這個 –

+0

我正在使用weight屬性 – param

回答

1

拆分主要容器的2個部分登錄部分設置重量2,底部爲1,然後添加容器的寬度和高度= match_parent和第一部分完成,然後設置容器的填充,那些容器本身可以是相關的嵌套在線性容器中,所以它更容易組成登錄部分。

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

    <RelativeLayout 
     android:layout_weight="1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RelativeLayout > 
      Your views here 
     </RelativeLayout> 

    </RelativeLayout> 

    <RelativeLayout 
     android:layout_weight="2" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RelativeLayout > 
      Your views here 
     </RelativeLayout> 
    </RelativeLayout> 

</LinearLayout>