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 sp, I tried it on the following emulators 5.1", pixel, pixel 10" tablet, pixel 2, pixel 2 XL and the nexus 7
my layouts actually work fine on these, but on the nexus 4 with a smaller dpi it gets ruined.
Edit: even with the cardview constrains set to match_parent, it still doesn't fix it, nothing happens.
as for physical devices, it works fine on my phone with a high dpi of 499, but my two other phones without high dpi, it gets ruined.
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity"
android:background="@drawable/withoutgrid">
<!--grid layout to hold two cards-->
<android.support.v7.widget.GridLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:paddingBottom="40dp"
app:columnCount="2"
app:columnOrderPreserved="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.755"
app:rowCount="1">
<!--first card layout-->
<android.support.v7.widget.CardView
android:id="@+id/cardView1"
android:layout_width="170dp"
android:layout_height="290dp"
android:layout_margin="12dp"
android:onClick="sPlayer"
app:cardBackgroundColor="@color/backgroundColor"
app:cardCornerRadius="30dp"
app:cardElevation="10dp"
app:layout_columnWeight="1"
app:layout_rowWeight="1">
<ImageButton
android:id="@+id/singleplayer"
android:layout_width="150dp"
android:layout_height="170dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="@null"
android:onClick="sPlayer"
android:paddingBottom="20dp"
android:scaleType="fitXY"
android:src="@drawable/robotfinal2" />
<TextView
android:id="@+id/singleplayertext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom|center_horizontal"
android:onClick="sPlayer"
android:paddingBottom="16dp"
android:text="Single Player"
android:textColor="@android:color/white"
android:textSize="24sp" />
</android.support.v7.widget.CardView>
</android.support.v7.widget.CardView>
<!--copy paste for second card layout-->
</android.support.v7.widget.GridLayout>
here are some screenshots from 2 same devices one with custom high dpi and another with stock dpi