Bottom navigation bar hides part of the view

In my application, I want to display a simple image,

On my Samsung Galaxy S7 Real device, the image is beautiful, the bottom navigation bar is not part of the view but is part of the phone itself. In general, the image is present.

In Android emulator the bottom navigation bar is part of the view and the image is partially hidden

Here is my simple linear layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout         
    xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          android:background="@color/md_blue_50"
          android:orientation="vertical">

    <include
        android:id="@+id/app_bar"
        layout="@layout/toolbar"/>

    <ImageView
        android:id="@+id/photo_image_large"
        android:adjustViewBounds="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="fill_vertical"
        android:scaleType="fitXY"/>

</LinearLayout>

      

Here is a screenshot of Android Emulator

Android emulator

Here is my Samsung Galaxy Real Device Screenshot

real android device

The problem also occurs in recycler Views in the app, the bottom of the image is cropped on the android emulator ...

+3


source to share


3 answers


This is because of android:fitSystemWindows

putting it to false and should be fine



+2


source


you need to place the view above the bottom nav bar so that the view is not hidden in the bottom nav bar



0


source


I had similar problems with BottomNavigationView (menu), this is the solution:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_activity_main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

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


<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="start"
    app:itemIconTint="@color/color_main_white"
    app:itemTextColor="@color/color_main_white"
    app:menu="@menu/bottom_navigation_menu"/> 

      

Try to change android: layout_heigh to 0dp and add this android: layout_weight = "1" for ImageView

0


source







All Articles