I have a problem with layout which won't stretch within high resolution like 1920x1080. As root layout I use Constraint Layout with following style:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context="njc.nhutrinhgold.MainActivity">
<ImageView
android:id="@+id/imgNen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:visibility="visible"
app:layout_constraintDimensionRatio="16:9"
app:srcCompat="@drawable/xxhdpibg"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"
tools:layout_width="match_parent" />
and in Manifest.xml
<supports-screens
android:anyDensity="true"
android:compatibleWidthLimitDp="960"
android:largeScreens="true"
android:largestWidthLimitDp="960"
android:normalScreens="false"
android:requiresSmallestWidthDp="960"
android:resizeable="false"
android:smallScreens="false"
android:xlargeScreens="true" />
I want to stretch layout to any screen resolution but on emulator with high resolution it looks like this:

Actually I didn't figured out what is the problem
Do it like this, and tell me what are you getting, because this is the ideal way of doing this, since everybody is saying the same thing but do it like this. match_parent is generally the key
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context="njc.nhutrinhgold.MainActivity">
<ImageView
android:id="@+id/imgNen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centreCrop"
android:visibility="visible"
app:layout_constraintDimensionRatio="16:9"
app:srcCompat="@drawable/xxhdpibg"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="8dp"
tools:layout_width="match_parent" />
Remove adjustViewBound and set the scaleType as centreCrop, you'll see the change
**NOTE : ** This is for the layout to take up the whole screen and adjust (stretching to the whole screen)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With