Reputation: 3780
I have an image that has resolution in order to fit whole screen on my test device. When tested with other screen sizes, image fits only width or height and leaves an empty space because it always scales proportional. How could I set image to fit fullscreen also if proportion changes? For example, if my device screen is 3/4, image will be properly scaled on 3/4 displays independent on its resolution. However, for a 16/9 will not fit fullscreen.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="@color/blueish"
android:layout_height="fill_parent">
<ImageView
android:src="@drawable/splashandroid"
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
also tried wrap_content for image layout width
Upvotes: 1
Views: 6902
Reputation: 12134
Add this in you ImageView, android:scaleType="fitXY"
or you can use this in you activity means imgview.setScaleType(ScaleType.FIT_XY);
You can try with this,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="@color/blueish"
android:layout_height="fill_parent">
<ImageView
android:src="@drawable/splashandroid"
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"/>
</LinearLayout>
Upvotes: 4