0

I have to manage gridview as below. Please sugges how can I manage gridview as it is image.

enter image description here

I am using following xml code

 <GridView
            android:id="@+id/tags_dialog_list"
            android:layout_width="match_parent"
            android:layout_height="@dimen/dialog_internal_list_height"
            android:layout_marginTop="2dp"
            android:choiceMode="singleChoice"
            android:horizontalSpacing="@dimen/tags_grid_item_divider_size"
            android:numColumns="auto_fit"
            android:layout_marginLeft="@dimen/tags_grid_item_divider_size"

            android:verticalSpacing="@dimen/tags_grid_item_divider_size" />

1 Answers1

0

Your picture is not a grid. A grid would look completely symmetrical like a chess board. What you have in your picture is a flow layout.

There are some open source flow layout solutions such as ApmeM/android-flowlayout and blazsolar/FlowLayout, but your picture is even more interesting since the lines are fill justified, which I don't think either of these layouts can do. You will probably need to write your own layout.

You should look at the flow layout code for the basics, but you will need to add some logic that takes all the items in the line and expands them proportionately until the left and right sides are even and all the inner spaces are equal.

kris larson
  • 30,387
  • 5
  • 62
  • 74