@artto8

Как настроить расположение view в layout?

Привет! Загружаю разные фото в ImageView, выглядит как-то так
скрин 1
5b3e505dcde5e788379195.jpeg

Фото разного размера, хочу чтобы ширина ImageView была максимальной, а высота подпиралась под фото. Но после смены нескольких изображений получаю такой результат
скрин 2
5b3e50ee0052f702518511.jpeg

Как реализовать задуманное? И ещё как задать максимальный размер, чтобы view не вышли за рамки экрана?
Код
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".View.RepostView"
    android:orientation="vertical"
    android:padding="10dp">

    <ImageView
        android:id="@+id/iv_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/iv_background"
        android:contentDescription="@string/iv_description"
        android:padding="5dp"
        android:scaleType="fitCenter"
        android:layout_marginBottom="5dp"/>

    <EditText
        android:id="@+id/et_description"
        android:layout_width="match_parent"
        android:layout_height="130dp"
        android:background="@drawable/et_background"
        android:elevation="4dp"
        android:inputType="textMultiLine|textNoSuggestions"
        android:padding="5dp"
        android:textColor="@android:color/white"
        android:textSize="14sp"
        android:gravity="top"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_horizontal">

        <Button
            android:id="@+id/button"
            style="@style/Widget.AppCompat.Button.Colored"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:elevation="4dp"
            android:onClick="onClickSave"
            android:text="@string/b_save" />

        <Button
            android:id="@+id/button2"
            style="@style/Widget.AppCompat.Button.Colored"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:elevation="4dp"
            android:onClick="onClickRepost"
            android:text="@string/b_repost" />
    </LinearLayout>
</LinearLayout>
  • Вопрос задан
  • 169 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы