I am facing a problem and I have searched a lot about it but couldn't find a solution.
I used a grid layout in my design and it works fine with API level > 19, but when I run my App on API level 19 it doesn't work properly:
Here is a screenshot of my App running on API level > 19: Screenshot (when API level > 19)
And on API level 19: Screenshot (when API = 19)
I tried adding these lines to the gradle file but they didn't help:
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
And here is my layout.xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:background="@drawable/bg"
android:weightSum="10"
android:padding="10dp"
tools:context=".ui.home.HomeActivity">
<ImageView
android:layout_weight="1"
android:layout_gravity="center"
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="120dp"
app:srcCompat="@drawable/azkar_logo" />
<GridLayout
android:columnCount="2"
android:rowCount="2"
android:alignmentMode="alignMargins"
android:columnOrderPreserved="true"
android:padding="5dp"
android:layout_weight="8"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Row 1 -->
<!-- Column 1 -->
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:cardElevation="8dp"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:onClick="startSalah"
android:layout_gravity="center_horizontal"
android:src="@drawable/praying"
android:layout_width="wrap_content"
android:layout_height="90dp" />
<TextView
android:textAlignment="center"
android:text="@string/salah"
android:textColor="@color/colorAccent"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.CardView>
<!-- Column 2 -->
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:cardElevation="8dp"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:onClick="startQuran"
android:layout_width="wrap_content"
android:layout_height="90dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerInside"
android:src="@drawable/quran" />
<TextView
android:textAlignment="center"
android:text="@string/quran"
android:textColor="@color/colorAccent"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.CardView>
<!-- Row 2 -->
<!-- Column 1 -->
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:cardElevation="8dp"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:onClick="startSonan"
android:layout_gravity="center_horizontal"
android:src="@drawable/sonan"
android:layout_width="wrap_content"
android:layout_height="90dp" />
<TextView
android:textAlignment="center"
android:text="@string/sonan"
android:textColor="@color/colorAccent"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.CardView>
<!-- Column 2 -->
<android.support.v7.widget.CardView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:cardElevation="8dp"
app:cardCornerRadius="8dp">
<LinearLayout
android:layout_gravity="center_horizontal|center_vertical"
android:layout_margin="16dp"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:onClick="startSadaqa"
android:layout_width="wrap_content"
android:layout_height="90dp"
android:layout_gravity="center_horizontal"
android:scaleType="centerInside"
android:src="@drawable/sadaqah" />
<TextView
android:textAlignment="center"
android:text="@string/sadaqah"
android:textColor="@color/colorAccent"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.CardView>
</GridLayout>
<LinearLayout
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_main_score"
android:onClick="showPoints"
android:text="@string/score"
android:textColor="@color/white"
android:textAlignment="center"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
Any help on this would be greatly appreciated.