简体   繁体   中英

Align LinearLayout to bottom, under ViewPager that fills screen

How can I create layout like this properly?

在此处输入图片说明

I want LinearLayout 2 under ViewPager (not inside).

I know there are few ways to archieve this, but what is the best way?

You must set layout_weight your viewpager. You can use this xml copy paste.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"></LinearLayout>

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"></LinearLayout>
</LinearLayout>

Put all your controls in RelativeLayout control

use this in ViewPager control with this attribute

android:layout_below="@+id/linearlayout1"
android:layout_above="@+id/linearlayout2"

android:layout_alignParentBottom="true" on LinearLayout 2.

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