2013-04-03 36 views
1

我有一個FrameLayout,它上面顯示一個LinearLayout 我的意圖是,這個LinearLayout總是達到屏幕的33%......但我不能這樣做。 我試過使用「dp」,但當然,結果根據密度而不同。 如果他們是兩個LinearLayout,如果我可以使用layout_weight =「.33」和layout_weight =「.67」 但FrameLayout用於其中之一。FrameLayout和屏幕的百分比

我希望能提前好好解釋一下它

enter image description here

感謝

問候

回答

3

YOUT可以嘗試這樣的事情。 第一層是ImageView,第二層有兩個線性佈局。

<FrameLayout 
    android:layoit_height="match_parent" 
    android:layout_width="match_parent"> 
    <ImageView 
     android:layoit_height="match_parent" 
     android:layout_width="match_parent" 
     android:image="@drawable/screen_image"/> //blue image whith white "screen" 

    <LinearLayout 
     android:layoit_height="match_parent" 
     android:layout_width="match_parent"> 
     <LinearLayout 
      android:layoit_height="0dp" 
      android:layout_weight=".67" 
      android:layout_width="match_parent" 
      android:background="#00000000"/> 

     <LinearLayout 
      android:layoit_height="0dp" 
      android:layout_weight=".33" 
      android:layout_width="match_parent" 
      android:background="#44FF0000"> //33% layout 

      //children for 33% layout here 

     </LinearLayout> 
    </LinearLayout> 

</FrameLayout> 
+0

問題是,我不需要頂部LinearLayout:( – Sergio76 2013-04-04 08:33:18

+0

使用值「不可見」在上面的佈局,可以工作。謝謝;) – Sergio76 2013-04-04 08:55:38

+0

@MiguelC我希望我的解決方案將對你有用。 – WELLCZECH 2013-04-04 09:28:37