将 LinearLayout 对齐到底部,在填满屏幕的 ViewPager 下
Align LinearLayout to bottom, under ViewPager that fills screen
如何正确创建这样的布局?
我想要 ViewPager 下的 LinearLayout 2(不在里面)。
我知道实现此目标的方法很少,但最好的方法是什么?
您必须设置 layout_weight 您的 viewpager。您可以使用此 xml 复制粘贴。
<?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>
将所有控件放在 RelativeLayout
控件中
在具有此属性的 ViewPager
控件中使用此
android:layout_below="@+id/linearlayout1"
android:layout_above="@+id/linearlayout2"
android:layout_alignParentBottom="true"
在 LinearLayout 2 上。
如何正确创建这样的布局?
我想要 ViewPager 下的 LinearLayout 2(不在里面)。
我知道实现此目标的方法很少,但最好的方法是什么?
您必须设置 layout_weight 您的 viewpager。您可以使用此 xml 复制粘贴。
<?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>
将所有控件放在 RelativeLayout
控件中
在具有此属性的 ViewPager
控件中使用此
android:layout_below="@+id/linearlayout1"
android:layout_above="@+id/linearlayout2"
android:layout_alignParentBottom="true"
在 LinearLayout 2 上。