Customizing the use of NavigationView

NavigationView navigationView = (NavigationView)findViewById(R.id.nav_view); iv_haederdrawer = (ImageView)navigationView.getHeaderView(0).findViewById(R.id.iv_haederdrawer); Picasso.with(NewsActivity.this).load("http://cs635102.vk.me/v635102610/5f40/f0oxmR2iluw.jpg").into(iv_haederdrawer); 

XML markup

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="100dp" android:background="@color/drawerBackground" android:theme="@style/ThemeOverlay.AppCompat.Dark" android:gravity="bottom"> <ImageView android:layout_width="100dp" android:layout_height="90dp" android:adjustViewBounds="true" android:orientation="vertical" android:scaleType="fitStart" android:id="@+id/iv_haederdrawer" tools:ignore="RtlCompat" android:layout_alignParentLeft="false" android:longClickable="true"> </ImageView> 

It turns out that the picture instead of the set 90 dp, takes 100. And it does not decrease in the right proportions. I tried to apply different styles to the picture, nothing helps - the piece is not enough (about 10 dp from the top). What surprises me most is that the markup is moving out. I use Lenovo 6010 Android 5.0.2. On the tablet with the old android 4.4.2 everything is displayed correctly. Please tell where the problem is. I wonder who else what methods you use to reduce the pictures.

Here's how it happened: Eaten 10dp

Here is how I want:

enter image description here

  • You'd better have attached more screenshots of how it should be and how it actually happened - Android Android
  • Experiment with the android:scaleType="fitStart attribute android:scaleType="fitStart - Vladyslav Matviienko
  • experimented, it's not a problem in him! - Ivan Vovk

1 answer 1

You have a picture left under statusBar. On the android above the 5th, the navigationView may overlap it. And be transparent. Most likely you have somewhere in the styles / markup indicated something like fitSystemWindows.

  • one
    You are absolutely right! Thank you so much! - Ivan Vovk