Мне было довольно сложно заставить мой макет работать, но теперь я закрыл его, за исключением того, чтобы получить заголовки до 2 объектов ImageButton, чтобы они соответствовали изображениям на экране. Мне нужны заголовки для ImageButtons, чтобы они были справа от изображений.Как получить TextView (заголовки) в LinearLayout для соответствия соответствующим объектам ImageButton?
Это намного проще визуализировать, так что ниже представлены два фото. Во-первых, как обстоят дела сейчас, а во-вторых, как я хочу, чтобы они смотрели. Я покрасил фон в основные части, чтобы вам было легче подключить виджеты xml к тому, что видно на устройстве. Как только я получу все правильно, я просто удалю атрибут фона.
Какие вещи выглядят как сейчас:
Что мне нужно вещи, чтобы выглядеть. Обратите внимание, выравнивание текста справа от двух изображений кнопок:
XML-макет:
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".35"
android:background="@color/LightGreen"
>
<Space
android:layout_width="match_parent"
android:layout_weight=".2"
android:layout_height="0dp"/>
<ImageView
android:id="@+id/imgViewLogo"
android:src="@drawable/logo"
android:layout_margin="10dp"
android:layout_width="90dp"
android:layout_height="0dp"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:layout_weight=".55"
/>
<Space
android:layout_width="match_parent"
android:layout_height="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Temporary Title for Logo"
android:id="@+id/tvAILLogo"
android:layout_margin="2dp"
android:textSize="@dimen/font_size22"
android:textStyle="bold"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:layout_weight=".25"
/>
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".1"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".4"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".5"
android:background="@color/LightCoral"
>
<ImageButton
android:id="@+id/imgBtn1"
android:src="@drawable/imgbtn1"
android:layout_width="90dp"
android:layout_height="95dp"
android:background="@null"
android:layout_gravity="right"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
/>
<Space
android:layout_width="match_parent"
android:layout_height="15dp"
/>
<ImageButton
android:id="@+id/imgBtn2"
android:src="@drawable/imgbtn2"
android:layout_width="90dp"
android:layout_height="95dp"
android:background="@null"
android:layout_gravity="right"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".5"
android:background="@color/LightYellow"
>
<TextView
android:id="@+id/tvGradeAssessment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Title1"
android:textColor="@color/white"
android:textSize="@dimen/font_size24"
android:paddingLeft="10dp"
android:layout_gravity="left"
android:background="@color/red"
/>
<Space
android:layout_width="match_parent"
android:layout_height="15dp"
/>
<TextView
android:id="@+id/tvPrivateData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Title2"
android:textColor="@color/white"
android:textSize="@dimen/font_size24"
android:paddingLeft="10dp"
android:background="@color/green"
android:layout_gravity="left"
/>
</LinearLayout>
</LinearLayout>
<!-- filler -->
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".05"
/>
<TextView
android:id="@+id/tvVersionNumber"
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="[Version number]"
android:layout_gravity="bottom"
android:paddingLeft="15dp"
android:layout_weight=".1"
android:textSize="20sp"
android:background="@color/LightGrey"
/>
</LinearLayout>
Ognian - Высокие пятерки везде. Это именно то, что я искал. Хотел бы я сам это понять. Благодарю. – Alyoshak