Android 相对布局-自动换行

Android 相对布局-自动换行,android,android-imageview,android-relativelayout,android-wrap-content,Android,Android Imageview,Android Relativelayout,Android Wrap Content,我有以下代码片段: <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_heig

我有以下代码片段:

<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>

我喜欢把ImageView放在左边,把第二个TextView放在这张图片的右边,或者根据图片的大小将图片卸载。 图像应该增长,直到达到140dp的最大高度

如果图像太宽,如何自动包装文本? 不幸的是,我现在不知道怎么做。 是的,我可以通过编程实现,但我喜欢只使用xml来实现这一目标


如果在其他布局中可能出现这种行为,则包装RelativeLayout不必是RelativeLayout。

听起来您需要一个
流程布局。Android没有提供开箱即用的解决方案,但看看这个答案

多亏了chessdork的回答,我找到了google的flexbox布局。 它由以下git存储库提供。