简体   繁体   中英

How to make a layout with fixed sides and expandable center?

What do you think would be the best way to make such layout in android?

It should fill the screen's resolution, while having the left and right part fixed 150px in width, but the center part should stretch out as needed.

在此处输入图片说明

Thanks!

Best approach will be to use 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>

use RelativeLayout, and take Three Views init:

LayoutParams of EachView should be as:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM