Xml 带有viewpager的布局底部的静态按钮

Xml 带有viewpager的布局底部的静态按钮,xml,button,android-viewpager,android-linearlayout,footer,Xml,Button,Android Viewpager,Android Linearlayout,Footer,我正在做一个项目,在那里我使用片段和viewpager,但在主屏幕上,我想要固定底部的选项卡,在底部我需要2个按钮。 我想在viewpager下面的屏幕末端添加2个按钮,我如何获得该按钮? 我做了几件事,但没有得到预期的结果 我想问的另一件事是,我应该改变我的主布局吗? 我试过了,但没有结果 这是我的代码帮助我 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xml

我正在做一个项目,在那里我使用片段和viewpager,但在主屏幕上,我想要固定底部的选项卡,在底部我需要2个按钮。 我想在viewpager下面的屏幕末端添加2个按钮,我如何获得该按钮? 我做了几件事,但没有得到预期的结果

我想问的另一件事是,我应该改变我的主布局吗? 我试过了,但没有结果

这是我的代码帮助我

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".AfterSendViewPager"
    android:orientation="vertical">
    
    
    <include
        layout="@layout/toolbar_layout"/>

    <com.google.android.material.tabs.TabLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/tablayout"
        android:background="#494545"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/ShapeAppearance.MaterialComponents.MediumComponent" />
    
    
    <androidx.viewpager.widget.ViewPager
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/viewpager"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:id="@+id/bottomupdatelayout"
        android:orientation="horizontal"

        >

        <com.google.android.material.button.MaterialButton
            android:layout_width="130dp"
            android:layout_height="wrap_content"
            android:id="@+id/selectedButtonBottom"
            android:theme="@style/Widget.MaterialComponents.Button.OutlinedButton"
            style="@style/Widget.MaterialComponents.Button.OutlinedButton"
            android:textColor="#2C771B"
            android:layout_margin="5dp"
            android:text="Selected"
            android:layout_weight="1"
            />

        <com.google.android.material.button.MaterialButton
            android:layout_width="130dp"
            android:layout_height="wrap_content"
            android:id="@+id/sendButtonBottom"
            android:theme="@style/Widget.MaterialComponents.Button.OutlinedButton"
            style="@style/Widget.MaterialComponents.Button.OutlinedButton"
            android:textColor="#2C771B"
            android:layout_margin="5dp"
            android:text="Send"
            android:layout_weight="1"
            />


    </LinearLayout>




</LinearLayout>



提前谢谢☺

使用ConstraintLayout代替线性布局使用此代码

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">


    <include
        layout="@layout/header_layout"/>

    <com.google.android.material.tabs.TabLayout
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/tablayout"
        android:background="#494545"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/ShapeAppearance.MaterialComponents.MediumComponent" />

    <androidx.viewpager.widget.ViewPager
        app:layout_constraintTop_toBottomOf="@id/tablayout"
        app:layout_constraintBottom_toTopOf="@id/bottomupdatelayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="#00BCD4"
        android:id="@+id/viewpager"/>

    <LinearLayout
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/bottomupdatelayout"
        android:orientation="horizontal">

        <com.google.android.material.button.MaterialButton
            android:layout_width="130dp"
            android:layout_height="wrap_content"
            android:id="@+id/selectedButtonBottom"
            android:textColor="#2C771B"
            android:layout_margin="5dp"
            android:text="Selected"
            android:layout_weight="1"
            />

        <com.google.android.material.button.MaterialButton
            android:layout_width="130dp"
            android:layout_height="wrap_content"
            android:id="@+id/sendButtonBottom"
            android:textColor="#2C771B"
            android:layout_margin="5dp"
            android:text="Send"
            android:layout_weight="1"/>


    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>