Dynamic height of TextView within a GridLayout

Jul picture Jul · Sep 2, 2012 · Viewed 8.9k times · Source

I have a problem using GridLayout using library compatibility (not tried without). I am using app:layout_gravity="fill_horizontal" instead of android:layout_gravity="fill_horizontal" but all the content inside the TextView is not displayed. In order to display everything, I have to set the height of the TextView "Title" but I want a dynamic height, not a set height.

Any idea?

Answer

Sergii Pechenizkyi picture Sergii Pechenizkyi · Sep 12, 2013

You have to set layout_width="0dp" and layout_gravity="fill_horizontal" for the TextView.

<TextView
    android:layout_width="0dp"
    android:layout_gravity="fill_horizontal" />

Please, see full example here: https://groups.google.com/d/msg/android-developers/OmH3VBwesOQ/ZOGR0SGvC3cJ or here: http://daniel-codes.blogspot.com/2012/01/gridlayout-view-clipping-issues.html