片段不适合所有布局页面?

时间:2017-12-20 05:03:34

标签: android android-fragments

我有片段的问题,当我添加内容时不要到所有页面只停留在顶部,我想适合所有布局我使用BottomNavigationView底部应用程序使用片段来显示内容。 enter image description here

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 xmlns:app="http://schemas.android.com/apk/res-auto"
 app:layout_behavior="appbar_scrolling_view_behavior"
 tools:context="com.example.hp.votingsystemv1.Fragments.HelpFragment">

 <ImageView
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:src="@drawable/help"/>

 </FrameLayout>


 <?xml version="1.0" encoding="utf-8"?>
 <android.support.design.widget.CoordinatorLayout
 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:id="@+id/main_container"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context="com.example.hp.votingsystemv1.Activities.MainActivity">

<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"     
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<android.support.design.widget.BottomNavigationView            
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"         
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary"
app:menu="@menu/bottombar_menu"
app:itemTextColor="@color/colorWhite"
app:itemIconTint="@color/colorWhite">

</android.support.design.widget.BottomNavigationView>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>

1 个答案:

答案 0 :(得分:0)

使用此

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    app:layout_behavior="appbar_scrolling_view_behavior">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/ic_action_rupee" />

        <android.support.design.widget.CoordinatorLayout
            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:id="@+id/main_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context="com.example.hp.votingsystemv1.Activities.MainActivity">

            <FrameLayout
                android:id="@+id/frame_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <android.support.design.widget.BottomNavigationView
                    android:id="@+id/navigation"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:background="@color/colorPrimary"
                    >

                </android.support.design.widget.BottomNavigationView>
            </RelativeLayout>

        </android.support.design.widget.CoordinatorLayout>
</FrameLayout>