2014-04-08 70 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>