Можно ли сделать с помощью ConstraintLayout
такое обтекание текста вокруг картинки?
Т.е. текст в TextView
должен находиться справа и снизу от ImageView
, при этом картинка в ImageView
должна занимать всю видимую (свободную) высоту экрана, ширина картинки при этом должна быть такой, чтобы картинка имела правильные пропорции, и экран должен прокручиваться (скроллиться).
У меня получается заставить ImageView
быть равным по высоте контейнеру с сохранением пропорций, но текст при этом "уезжает" вправо:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/avatar"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintVertical_weight="1"
android:contentDescription="@string/avatar"
android:scaleType="centerCrop"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@tools:sample/avatars" />
<TextView
android:id="@+id/details"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingEnd="@dimen/margin"
android:paddingLeft="@dimen/margin"
android:paddingRight="@dimen/margin"
android:paddingStart="@dimen/margin"
app:layout_constraintLeft_toRightOf="@id/avatar"
app:layout_constraintStart_toEndOf="@id/avatar"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:text="@tools:sample/lorem" />
</androidx.constraintlayout.widget.ConstraintLayout>
И не получается сделать прокручивание, т.к. в случае, если я оборачиваю ConstraintLayout
в ScrollView
, ImageView
начинает занимать и невидимую часть экрана:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Если же обернуть TextView
в ScrollView
, размер картинки правильный, но прокручивается только текст справа, картинка остаётся на месте, а это не совсем то, что мне нужно - текст не обтекает картинку, а просто прокручивается справа от неё.
Или с помощью ConstraintLayout
и ScrollView
так сделать невозможно? C помощью каких контейнеров тогда лучше сделать такой макет?
onMeasure
и т.п. Хотя, почему-то мне кажется, есть готовый компонент с таким поведением)