My Layouts Aren't Scaling Properly On Low Dpi Devices
I made an android app with constrain layout, and the layout doesn't scale properly even thought I've used SP and DP as units. I double checked all values and they all have dp and s
Solution 1:
One of the issues here is that you are testing the layout on small screen sizes such as the Nexus 4 which is about 4.7 inches.
You probably did not develop the application with the initial design focused on such a small screen size.
Consider creating alternate layouts for different screen sizes.
Supporting different screen sizes would help.
Check this link out: Support different screen sizes
Solution 2:
I have used Guideline in the center of the screen to make this go easier and it works for me, try to use this layout :
<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayoutxmlns: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"><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginStart="8dp"android:layout_marginTop="8dp"android:layout_marginEnd="8dp"android:text="Button"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHorizontal_bias="0.5"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><Buttonandroid:id="@+id/button5"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_marginStart="8dp"android:layout_marginEnd="8dp"android:layout_marginBottom="8dp"android:text="Button"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent" /><ImageViewandroid:id="@+id/imageView3"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_marginStart="8dp"android:layout_marginEnd="8dp"android:layout_marginBottom="8dp"app:layout_constraintBottom_toTopOf="@+id/button5"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="@+id/guideline"app:srcCompat="@android:drawable/ic_menu_report_image" /><ImageViewandroid:id="@+id/imageView4"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_marginStart="8dp"android:layout_marginEnd="8dp"android:layout_marginBottom="12dp"app:layout_constraintBottom_toTopOf="@+id/button5"app:layout_constraintEnd_toStartOf="@+id/guideline"app:layout_constraintStart_toStartOf="parent"app:srcCompat="@android:drawable/ic_menu_report_image" /><android.support.constraint.Guidelineandroid:id="@+id/guideline"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="vertical"app:layout_constraintGuide_percent="0.5" /></android.support.constraint.ConstraintLayout>
Post a Comment for "My Layouts Aren't Scaling Properly On Low Dpi Devices"