Grid layout doesn't work properly on API level 19?











up vote
2
down vote

favorite












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.










share|improve this question




























    up vote
    2
    down vote

    favorite












    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.










    share|improve this question


























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      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.










      share|improve this question















      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.







      android user-interface grid-layout






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 12:04









      Nitin Gurbani

      727215




      727215










      asked Nov 9 at 11:03









      Nasr

      134




      134
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          GridView is really outdated.
          You need to use RecyclerView with GridLayoutManager instead.



          Here is a simple example as how to use it:



          recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns));





          share|improve this answer























          • i will try it now
            – Nasr
            Nov 9 at 11:09










          • thanks i was tring to make it manually but it didint work. your solution solve it Thanks
            – Nasr
            Nov 9 at 11:12













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224500%2fgrid-layout-doesnt-work-properly-on-api-level-19%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          GridView is really outdated.
          You need to use RecyclerView with GridLayoutManager instead.



          Here is a simple example as how to use it:



          recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns));





          share|improve this answer























          • i will try it now
            – Nasr
            Nov 9 at 11:09










          • thanks i was tring to make it manually but it didint work. your solution solve it Thanks
            – Nasr
            Nov 9 at 11:12

















          up vote
          1
          down vote



          accepted










          GridView is really outdated.
          You need to use RecyclerView with GridLayoutManager instead.



          Here is a simple example as how to use it:



          recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns));





          share|improve this answer























          • i will try it now
            – Nasr
            Nov 9 at 11:09










          • thanks i was tring to make it manually but it didint work. your solution solve it Thanks
            – Nasr
            Nov 9 at 11:12















          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          GridView is really outdated.
          You need to use RecyclerView with GridLayoutManager instead.



          Here is a simple example as how to use it:



          recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns));





          share|improve this answer














          GridView is really outdated.
          You need to use RecyclerView with GridLayoutManager instead.



          Here is a simple example as how to use it:



          recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns));






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 9 at 12:12









          Nitin Gurbani

          727215




          727215










          answered Nov 9 at 11:07









          Onix

          4228




          4228












          • i will try it now
            – Nasr
            Nov 9 at 11:09










          • thanks i was tring to make it manually but it didint work. your solution solve it Thanks
            – Nasr
            Nov 9 at 11:12




















          • i will try it now
            – Nasr
            Nov 9 at 11:09










          • thanks i was tring to make it manually but it didint work. your solution solve it Thanks
            – Nasr
            Nov 9 at 11:12


















          i will try it now
          – Nasr
          Nov 9 at 11:09




          i will try it now
          – Nasr
          Nov 9 at 11:09












          thanks i was tring to make it manually but it didint work. your solution solve it Thanks
          – Nasr
          Nov 9 at 11:12






          thanks i was tring to make it manually but it didint work. your solution solve it Thanks
          – Nasr
          Nov 9 at 11:12




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224500%2fgrid-layout-doesnt-work-properly-on-api-level-19%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Academy of Television Arts & Sciences

          L'Équipe

          1995 France bombings