BottomNavigationView doest not shown currectly

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



BottomNavigationView doest not shown currectly



I'm adding a BottomNavigationView to My MainActivity
at first show nothing wrong but after click on other items, BottomNavigationView strangely moving up and down. In other projects, I had never this problem and I don't know why I am getting this:


BottomNavigationView


MainActivity


BottomNavigationView



p.s: In default fragment (which is first at right in screenshot) I have a content but in other fragments, I have no content.



Here is my MainActivity layout:


MainActivity




<?xml version="1.0" encoding="utf-8"?>
<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="com.activity.MainActivity">

<FrameLayout
android:id="@+id/MainActivity_FrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/MainActivity_BottomView" />


<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary"
app:menu="@menu/main_bottom_view_menu"
app:elevation="2dp"
app:itemTextColor="@android:color/white"
app:itemIconTint="@android:color/white"
android:id="@+id/MainActivity_BottomView"/>

</RelativeLayout>



and here is the screenshot of how does shown



after clicking on another item



and when select default item again



--- EDIT ---



I realized it's happen when use CoordinatorLayout , AppBarLayout and CollapsingToolbarLayout in fragment . After remove that lines app work without any problem .


CoordinatorLayout


AppBarLayout


CollapsingToolbarLayout



Here is my fragment Layout :




<android.support.design.widget.CoordinatorLayout 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"
android:background="#e2e2e2"
android:animateLayoutChanges="true"
android:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.fragment.MainFragments.ProfileFragment">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:background="@color/colorPrimaryDark"
android:layout_height="wrap_content">

<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimaryDark"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:titleEnabled="false"
app:scrimAnimationDuration="300"
android:layout_height="wrap_content">

<RelativeLayout
android:layout_width="match_parent"
android:background="@color/colorPrimaryDark"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="140dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:id="@+id/Profile_InfoContainer"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content">

<com.graymind.applog.customview.CircleImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/Profile_ProfilePhoto"
android:layout_marginTop="10dp"
android:scaleType="centerCrop"
app:srcCompat="@drawable/login_bg"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="25dp"
android:textColor="@android:color/white"
android:gravity="center"
android:id="@+id/Profile_FullName"
android:text="FullName"
android:textStyle="bold"/>

<TextView
android:id="@+id/Profile_Id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="'@gray_mind75"
android:textColor="@android:color/white"
android:textStyle="normal" />

</LinearLayout>

<TextView
android:id="@+id/Profile_Bio"
android:layout_width="match_parent"
android:layout_below="@+id/Profile_InfoContainer"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_marginBottom="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textSize="12sp"
android:lineSpacingExtra="4sp"/>
android:textColor="@android:color/white"
android:textDirection="rtl" />

<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:weightSum="3"
android:layout_below="@+id/Profile_Bio"
android:layout_height="50dp">

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:weightSum="1"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="1234"
android:textColor="@android:color/white"
android:textSize="@dimen/profile_stats_texts_size"
android:gravity="center"
tools:ignore="NestedWeights" />

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textSize="@dimen/profile_stats_texts_size"
android:textColor="@android:color/white"
android:gravity="center"
android:text="@string/post"/>

</LinearLayout>

<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/colorPrimary"/>

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:weightSum="1"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="1234"
android:textSize="@dimen/profile_stats_texts_size"
android:textColor="@android:color/white"
android:gravity="center"
tools:ignore="NestedWeights" />

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textColor="@android:color/white"
android:textSize="@dimen/profile_stats_texts_size"
android:gravity="center"
android:text="@string/followings"/>

</LinearLayout>

<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/colorPrimary"/>

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:weightSum="1"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="1234"
android:textSize="@dimen/profile_stats_texts_size"
android:textColor="@android:color/white"
android:gravity="center"
tools:ignore="NestedWeights" />

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:textSize="@dimen/profile_stats_texts_size"
android:textColor="@android:color/white"
android:gravity="center"
android:text="@string/followers"/>

</LinearLayout>

</LinearLayout>

</RelativeLayout>

<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
app:layout_collapseMode="pin"
android:layout_height="?attr/actionBarSize">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/profile"
android:gravity="center"
android:layout_toStartOf="@+id/Profile_ToolbarProfileIcon"
android:textColor="@android:color/white"
android:layout_marginEnd="10dp"/>

<ImageView
android:layout_width="30dp"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:id="@+id/Profile_ToolbarProfileIcon"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_profile"
android:tint="@android:color/white"
android:layout_alignParentEnd="true"/>

</RelativeLayout>
</android.support.v7.widget.Toolbar>

</android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/ProfilePostsScrollView"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:requiresFadingEdge="none"
android:id="@+id/Profile_PostsRecycler"/>

</android.support.v4.widget.NestedScrollView>

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



Thanks in advance for your guidance.




1 Answer
1



Change your root layout to LinearLayout like below:


<?xml version="1.0" encoding="utf-8"?>
<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"
android:orientation="vertical"
tools:context="com.activity.MainActivity">

<FrameLayout
android:id="@+id/MainActivity_FrameLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />

<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:menu="@menu/main_bottom_view_menu"
app:elevation="2dp"
app:itemTextColor="@android:color/white"
app:itemIconTint="@android:color/white"
android:id="@+id/MainActivity_BottomView" />

</LinearLayout>





thanks for answer but unfortunately still have that problem
– BeNYaMiN
Aug 12 at 5:12





@BeNYaMiN I updated my answer, please check it again
– Mosius
Aug 12 at 5:22





yes i got that typo, see above my edit . Thanks
– BeNYaMiN
Aug 12 at 5:38






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard