Sai
Sai

Reputation: 15718

Imageview is not filling its parent

  1. Image with size (width: 1080px height: 1920px)
  2. Phone is xxhdpi which has a resolution of (width: 1080px height: 1920px)

In output you can see there is a white gap in start and end of the imageView.

I don't want to use android:scaleType="fitXY" because it stretches the image. I know the gaps is because of the status bar and navigation bar the imageview tries to maintain its ratio.

Is it possible to fill the imageview without doing anything to the image source.Thanks in advance.

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

<ImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/plain" />

Output: sample output

Upvotes: 0

Views: 670

Answers (1)

志威梦
志威梦

Reputation: 136

Since you don't want to use fitXY,or modify the img,maybe you can use android:background="@drawable/img" replace android:src=@drawable/img,Did you like this?

Upvotes: 1

Related Questions