[英]How to make a layout with fixed sides and expandable center?
您認為在android中進行這種布局的最佳方法是什么?
左右部分的寬度固定為150px,但它應該填充屏幕的分辨率,但中間部分應根據需要伸展。
謝謝!
最好的方法是使用LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<View
android:layout_width="150px"
android:layout_height="fill_parent"
android:layout_weight="0"/>
<View
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<View
android:layout_width="150px"
android:layout_height="fill_parent"
android:layout_weight="0"/>
</LinearLayout>
使用RelativeLayout,並采用三個視圖init:
EachView的LayoutParams應該為:
View1-- id- @ + id / view1 Layout_Width = wrap_content Layout_Height = wrap_content
view2:id- @ + id / view2 Layout_Width = fill_parent Layout_Height = wrap_content toLeftOF = @ + id / view3 toRightOf = @ + id / view1
view3:id- @ + id / view2 Layout_Width = wrap_content Layout_Height = wrap_content align_parent_right = true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.