2016-12-28 27 views
0

我需要開發3列的景觀設計。Android 3列設計

左邊和右邊將有一個特定的大小,最好是可用寬度的百分比,比如每個10%。

中間一個需要佔用剩餘的80%的屏幕。

哪個是開發它的最佳方法? 我的代碼是

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingLeft="16dp" 
android:paddingRight="16dp" 
android:orientation="horizontal" 

android:screenOrientation="landscape" 
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
android:background="@drawable/background"> 



<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="10"> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="7"> 


     <LinearLayout 
      android:orientation="vertical" 
      android:layout_height="match_parent" 
      android:layout_width="100dp" 
      android:layout_gravity="left" 
      android:layout_weight="0.2"> 

      ... 

     </LinearLayout> 

     <GridLayout 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:columnCount="7" 
      android:rowCount="4" 
      android:layout_gravity="center" 
      android:layout_weight="0.6"> 

      ... 

     </GridLayout> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="100dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="right" 
      android:layout_weight="0.2"> 

      ..... 

     </LinearLayout> 


    </LinearLayout> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="90"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/offer_taken" 
      android:layout_weight="1" 
      android:text="gfhfg hg" /> 
    </LinearLayout> 
</LinearLayout> 

+0

類似添加weightSum父佈局 –

回答

1

你可以這樣做

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingLeft="16dp" 
android:paddingRight="16dp" 
android:orientation="horizontal" 
android:screenOrientation="landscape" 
android:weightSum="10" 
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> 


<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="1"> 

    .... 

</LinearLayout> 

<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="8"> 

    .... 

</LinearLayout> 

<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="1"> 

    .... 

</LinearLayout> 


</LinearLayout>