在导航时,bottomNaviagtionview的高度在某些项目中变得最小

问题描述 投票:0回答:1

我在bottomNavigationView有一个MainActivity。当我点击第二个(SearchFragment)和最后一个(AccountFragment)项目时,bottomNavigationView的高度变小,当再次点击相同的菜单项时,bottomNavigationView的高度变得正常。这只发生在我在家里的项目(HomeFragment)从那里我导航到第二个或最后一个项目。在第三个菜单项(MyCourseFragment)中没有这个问题。 Trouble Mode它是正常状态的屏幕截图:Normal Mode这是MainActivity的布局:

    <android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <FrameLayout
        android:id="@+id/flContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="56dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <ProgressBar
            android:id="@+id/progressBar"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:visibility="visible"/>
    </FrameLayout>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_nav"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:menu="@menu/bottom_nav_menu"
        app:itemBackground="@color/colorBackgroundNav"
        android:theme="@style/bottomNav"
        app:labelVisibilityMode="labeled"
        android:layout_gravity="bottom"
        />
</android.support.design.widget.CoordinatorLayout>

它是MyCourseFragment的布局:

     <RelativeLayout xmlns:tools="http://schemas.android.com/tools"
        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"
        tools:context=".view.MyCourseFragment">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_collapseMode="pin"
            android:background="@color/colorPrimary">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="دوره های من"
                android:layout_gravity="end"
                android:id="@+id/toolbar_title"
                android:layout_marginEnd="20dp"
                android:textColor="#fff"
                android:textStyle="bold"
                android:textSize="17sp"/>
        </android.support.v7.widget.Toolbar>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/courseRcy"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:layout_marginTop="30dp"
            android:visibility="gone"/>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/categoryRcy"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:layout_marginTop="30dp"/>
    </RelativeLayout>
It is layout of `SearchFragment`:

    <RelativeLayout 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=".view.SearchFragment">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

    <SearchView
        android:id="@+id/searchbox"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_centerInParent="true"
        android:layout_margin="10dp"
        android:background="#FFF"></SearchView>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/CategoryRcy"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/searchbox"
        android:layout_marginTop="10dp" />

</RelativeLayout>

布局'AccountFragment':

    <ScrollView android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

<RelativeLayout 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"
    tools:context=".view.AccountFragment">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:fitsSystemWindows="true"
        android:minHeight="?attr/actionBarSize"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="حساب کاربری"
            android:layout_gravity="end"
            android:id="@+id/toolbar_title"
            android:layout_marginEnd="20dp"
            android:textColor="#fff"
            android:textStyle="bold"
            android:textSize="17sp"/>
    </android.support.v7.widget.Toolbar>

    <android.support.v7.widget.CardView
        android:id="@+id/cardViewProfile"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        app:cardCornerRadius="15dp"
        android:layout_below="@+id/toolbar"
        android:visibility="gone">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <ImageView
                android:id="@+id/imgAvatar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_avatar"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="20dp"/>
            <TextView
                android:id="@+id/txtName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="مریم کاظمی"
                android:layout_below="@id/imgAvatar"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dp"
                />
        </RelativeLayout>
    </android.support.v7.widget.CardView>
    <android.support.v7.widget.CardView
        android:id="@+id/cardViewInstructor"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/cardViewProfile"
        android:layout_marginTop="20dp"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        app:cardCornerRadius="15dp"
        android:padding="10dp"
        android:visibility="gone">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <TextView
            android:id="@+id/txtBeInstructor"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="یک مدرس شو"
            android:layout_centerInParent="true"
            android:textColor="@color/colorPrimary"
            android:textStyle="bold"
            android:textSize="20sp"
            />
        </RelativeLayout>
    </android.support.v7.widget.CardView>
    <android.support.v7.widget.CardView
        android:id="@+id/cardViewSetting"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/cardViewInstructor"
        android:layout_marginTop="20dp"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        app:cardCornerRadius="15dp"
        android:visibility="gone">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <TextView
                android:id="@+id/txtPreferences"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                android:text="تنظیمات"/>
            <TextView
                android:id="@+id/txtLecturePlayBack"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                android:text="پخش دوره"
                android:layout_below="@+id/txtPreferences"/>
            <TextView
                android:id="@+id/txtContinueBackground"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="10dp"
                android:text="پخش پیوسته در بک گراند"
                android:layout_below="@+id/txtLecturePlayBack"/>
            <Switch
                android:id="@+id/switchCB"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/txtLecturePlayBack"
                android:layout_marginTop="10dp"
                android:layout_marginStart="20dp"/>
            <TextView
                android:id="@+id/txtDownloadOption"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                android:text="گزینه های دانلود ویدیو"
                android:layout_below="@+id/txtContinueBackground"/>
            <TextView
                android:id="@+id/txtDWiFi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="10dp"
                android:text="دانلود فقط از طریق Wi-Fi"
                android:layout_below="@+id/txtDownloadOption"/>
            <Switch
                android:id="@+id/switchDWifi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/txtDownloadOption"
                android:layout_marginTop="10dp"
                android:layout_marginStart="20dp"/>
            <TextView
                android:id="@+id/txtDSD"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                android:text="دانلود داخل کارت حافظه"
                android:layout_below="@+id/txtDWiFi"/>
            <Switch
                android:id="@+id/switchDSD"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/txtDWiFi"
                android:layout_marginTop="20dp"
                android:layout_marginStart="20dp"/>
            <TextView
                android:id="@+id/txtQualityVideo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                android:text="کیفیت دانلود ویدیو"
                android:layout_below="@+id/txtDSD"/>
            <TextView
                android:id="@+id/txtQuality"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/txtQualityVideo"
                android:layout_alignParentEnd="true"
                android:text="360p"
                android:layout_marginTop="5dp"
                android:layout_marginEnd="10dp"/>
            <TextView
                android:id="@+id/txtTitleEditNotf"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                android:text="تنظیمات نوتیفیکیشن"
                android:layout_below="@+id/txtQuality"/>
            <TextView
                android:id="@+id/txtEditNotf"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/txtTitleEditNotf"
                android:layout_alignParentEnd="true"
                android:text="ویرایش تنظیمات نوتیفیکیشن ها"
                android:layout_marginTop="10dp"
                android:layout_marginEnd="10dp"
                android:layout_marginBottom="20dp"/>
        </RelativeLayout>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:id="@+id/cardViewPolicy"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        app:cardCornerRadius="15dp"
        android:layout_below="@+id/cardViewSetting"
        android:visibility="visible"
        android:layout_marginBottom="10dp">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <TextView
                android:id="@+id/txtShareApp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="پارس کلاس را به اشتراک بگذار"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                />
            <TextView
                android:id="@+id/txtPrivacy"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="مشاهده سیاست های حریم خصوصی"
                android:layout_below="@+id/txtShareApp"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                />
            <TextView
                android:id="@+id/txtTermOfUse"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="مقررات  استفاده"
                android:layout_below="@+id/txtPrivacy"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                />
            <TextView
                android:id="@+id/txtIntellectual"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="مشاهده سیاست مالکیت معنوی"
                android:layout_below="@+id/txtTermOfUse"
                android:layout_alignParentEnd="true"
                android:layout_marginTop="20dp"
                android:layout_marginEnd="10dp"
                />
            <TextView
                android:id="@+id/txtSign"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="ورود/ثبت نام"
                android:layout_below="@+id/txtIntellectual"
                android:layout_centerInParent="true"
                android:layout_marginTop="10dp"/>
            <TextView
                android:id="@+id/txtVersion"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="ParsClass v1.1"
                android:layout_below="@+id/txtSign"
                android:layout_centerInParent="true"
                android:layout_marginTop="10dp"
                android:paddingBottom="10dp"/>
        </RelativeLayout>
    </android.support.v7.widget.CardView>

</RelativeLayout>
</ScrollView>
android android-layout android-fragments android-xml bottomnavigationview
1个回答
0
投票

最后我找到了解决方案。我只需要将这行代码添加到Account片段的onCreateView方法中。

((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
© www.soinside.com 2019 - 2024. All rights reserved.