0

I am trying to make layout like this enter image description here

I am trying to use GridLayout to achieve this but the issue I am getting is some buttons are small in size and some are bigger in size. For the small size buttons it should move the next button closer to the last button but its not doing that. Its doing this enter image description here

Any Idea of how to achieve this with Grid Layout or any other layout. This is the code for grid layout I am using

    <GridLayout
        android:layout_width="match_parent"
        android:layout_marginTop="@dimen/_16ssp"
        android:columnCount="3"

        android:layout_marginHorizontal="@dimen/_16ssp"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/_16ssp"
            android:background="@drawable/grey_20dp_10op"
            android:paddingHorizontal="@dimen/_32ssp"
            android:paddingVertical="@dimen/_8ssp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/regular"
                android:text="ALL"

                android:textColor="@color/black"
                android:textSize="@dimen/_12ssp"></TextView>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/_16ssp"
            android:background="@drawable/grey_20dp_10op"
            android:paddingHorizontal="@dimen/_32ssp"
            android:paddingVertical="@dimen/_8ssp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/regular"
                android:text="Default"

                android:textColor="@color/black"
                android:textSize="@dimen/_12ssp"></TextView>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/_16ssp"
            android:background="@drawable/grey_20dp_10op"
            android:paddingHorizontal="@dimen/_32ssp"
            android:paddingVertical="@dimen/_8ssp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/regular"
                android:text="Default"

                android:textColor="@color/black"
                android:textSize="@dimen/_12ssp"></TextView>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/_16ssp"
            android:layout_marginTop="@dimen/_16ssp"
            android:background="@drawable/grey_20dp_10op"
            android:paddingHorizontal="@dimen/_32ssp"
            android:paddingVertical="@dimen/_8ssp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/regular"
                android:text="Default"

                android:textColor="@color/black"
                android:textSize="@dimen/_12ssp"></TextView>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/_16ssp"
            android:layout_marginTop="@dimen/_16ssp"
            android:background="@drawable/grey_20dp_10op"
            android:paddingHorizontal="@dimen/_32ssp"
            android:paddingVertical="@dimen/_8ssp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/regular"
                android:text="Default"

                android:textColor="@color/black"
                android:textSize="@dimen/_12ssp"></TextView>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/_16ssp"
            android:layout_marginTop="@dimen/_16ssp"
            android:background="@drawable/grey_20dp_10op"
            android:paddingHorizontal="@dimen/_32ssp"
            android:paddingVertical="@dimen/_8ssp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/regular"
                android:text="Default"

                android:textColor="@color/black"
                android:textSize="@dimen/_12ssp"></TextView>
        </LinearLayout>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/_16ssp"
            android:layout_marginTop="@dimen/_16ssp"
            android:background="@drawable/grey_20dp_10op"
            android:paddingHorizontal="@dimen/_32ssp"
            android:paddingVertical="@dimen/_8ssp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fontFamily="@font/regular"
                android:text="Default"

                android:textColor="@color/black"
                android:textSize="@dimen/_12ssp"></TextView>
        </LinearLayout>




    </GridLayout>
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.