I have the following code snippet:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/collected_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/card_text_color"
android:textSize="@dimen/card_headline_textsize"
android:layout_marginBottom="@dimen/card_headline_marginBottom"
android:text="Foo" />
<ImageView
android:id="@+id/collected_item_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxHeight="140dp"
android:background="@android:color/holo_red_dark"
android:adjustViewBounds="true"
android:layout_below="@id/collected_item_title"
android:layout_marginEnd="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/collected_item_image"
android:layout_below="@id/collected_item_title"
android:text="Foo"
android:textColor="@color/card_text_color" />
</RelativeLayout>
I like to have the ImageView on the left and the second TextView either on the right of this image or unter the image, dependent on the size of the image. The image should grow, until it reaches a maximum height of 140dp.
How can I automatically wrap the text if the image get's too width? Unfortunately I have no idea at the moment how to do it. Yes I can do it programmatically, but I like to reach the goal only with xml.
The wrapping RelativeLayout doesn't have to be a RelativeLayout, if this behaviour is possible with an other layout.