Andy Cass
Andy Cass

Reputation: 446

Bottom navigation bar hides part of a view

In my app I want to display a simple Image,

On my Samsung Galaxy S7 Real device the image is fine, The bottom Navigation bar is not part of the view but part of the phone itself. The whole of the Image is present.

On the 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 the Android Emulator Screenshot

android emulator

Here is my Samsung Galaxy Real Device Screenshot

android real device

The problem also occurs in recycler Views in the app the bottom part of the image is cut off on the android emulator...

Upvotes: 6

Views: 4330

Answers (3)

Pretorian
Pretorian

Reputation: 169

I had similar problems with BottomNavigationView (menu) this is 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 parameter android:layout_heigh to 0dp and add this android:layout_weight="1" for ImageView

Upvotes: 1

Ler
Ler

Reputation: 146

It's because of android:fitSystemWindows put it to false and it should be good

Upvotes: 6

Dina Gar
Dina Gar

Reputation: 130

you have to place the view above the bottom navigation bar so that the view wont hide in the bottom navigation bar

Upvotes: 0

Related Questions