简体   繁体   中英

Put view between two Views with strict size

Is there any way to put my FrameLayout between 1.1 and 1.3. I tried to use layout_below and layout_above for it, but it doesn't work together.

1. RelativeLayout

1.1 RelativeLayout (strict_size)

1.2 FrameLayout (match_parent)

1.3 RelativeLayout (strict_size)

I would use a LinearLayout . Assuming you are talking about heights:

<LinearLayout
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="20dp">

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="20dp">

</LinearLayout>

When using layout_weight like that, LinearLayout will first lay out views with fixed dimensions, and then assign all the remaining space to the layout_weight="1" view.

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