1

I'm quite new to android. I wanted to show cards in a tabular form. I want 2 columns which should be exactly equal in length (even if the size of the content in one of the column increases).

For example, it should be like Play Store or Google Keep. My card will have 2 lines of data. First for Title and second for Description.

enter image description here

I tried many layouts; TableLayout, GridLayout etc. but neither worked actually. Lastly I read this SO post but it doesn't work if text size on my card increases.

Any idea on how this can be done? It will be a bonus if the Description text ellipsizes at end.

Community
  • 1
  • 1
Mangesh
  • 5,491
  • 5
  • 48
  • 71

1 Answers1

1

If I understand you well enough:

Try using a LinearLayout and setting the layout_weight of the items inside the layout. So you'll have something like:

<LinearLayout
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:orientation="horizontal">

    <Card
        android:id="@+id/card1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <Card
        android:id="@+id/card2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

</LinearLayout>

Then if you wanted to perhaps have multiple things in the columns just make those card items additional LinearLayouts of vertical orientation.

JoeBruzek
  • 509
  • 4
  • 16