I have to represent some short sentences in `TextViews`. I did that using a `recyclerView` with a `GridLayoutManager` and setting each sentence on a `TextView` on each cell of the grid. The thing is that I would like that each cell of the grid change its width according to the text in the `TextView`. I mean, a long sentence could take the screen full width, or if the sentence are very short, they must be on the same row. 

I also tried using a `GridView` but I couldn't get the desired result either.

Any idea about how to get that?

**EDIT**

*item.xml*

```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/unselected_term"
        android:padding="10dp">

        <TextView
            android:id="@+id/item_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textColor="@color/term_text"
            android:gravity="center"
            android:textSize="18sp"/>

</LinearLayout>

```

**EDIT 2**

[![Desired layout](https://i.stack.imgur.com/dz3wb.jpg)](https://i.stack.imgur.com/dz3wb.jpg)

This is an example of how the layout should look like. The lenght of each element won't be always the same. So I need a layout that let the larger elements having more width that the shorter ones.