2 колонки с изображением и текстом (Android Studio) - PullRequest
0 голосов
/ 20 октября 2019

Эй, я хочу создать макет с двумя столбцами, где у меня есть строка с изображением и текстом вроде этого: http://prntscr.com/plrpcf

У меня уже есть макет с двумя столбцами для кнопок, но я думаю, что мне нужночтобы обернуть изображение и текст в другой layoutcontainer

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        >

        <ImageButton
            android:id="@+id/button11"
            style="@style/Widget.AppCompat.Button.Colored"
            android:src="@drawable/1"
            android:layout_weight="1"
            android:layout_height="75dp"
            android:layout_width="1dp"

            android:text="1" />

        <ImageButton
            android:id="@+id/button12"
            style="@style/Widget.AppCompat.Button.Colored"
            android:src="@drawable/2"
            android:layout_weight="1"
            android:layout_height="75dp"
            android:layout_width="1dp"

            android:text="2" />

    </LinearLayout>

Я как-то работал с приведенным выше сценарием, но изображения действительно маленькие, они не растягиваются до полного размера родителя, любые идеи

На самом деле они растягиваются, если у меня есть статический источник изображений. Когда я загружаю их через скрипт, они становятся меньше

 <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="fill_parent"
                android:orientation="horizontal" >

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/img4"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:scaleType="fitCenter"
                        android:src="@drawable/thumb" />

                    <TextView
                        android:id="@+id/tex4"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="qweqweqwqweqwe" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@+id/img5"

                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:scaleType="fitCenter"
                        android:src="@drawable/thumb" />

                    <TextView
                        android:id="@+id/tex5"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="asdasdasasasdasd" />

                </LinearLayout>
            </LinearLayout>

1 Ответ

0 голосов
/ 20 октября 2019

Я решил это!

Используйте adjustviewBounds = true на изображениях, и оно растянет изображения!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...