Я хочу реализовать следующую схему:
Как лежать горизонтально эти виды?
Я сделал это следующим образом:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginRight="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LABEL"
android:textSize="14sp"
android:layout_marginBottom="5dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:padding="10dp"
android:text="Text Box 1"
android:textSize="14sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LABEL 2"
android:layout_marginBottom="5dp"
android:textSize="14sp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="BLA-1"
android:background="@color/white"
android:textSize="14sp"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center|bottom"
android:text="and"
android:textSize="14sp"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="BLA-2"
android:background="@color/white"
android:textSize="14sp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
В основном я использовал LinearLayouts и гравитацию.
Это работает, но кажется сложным, и я заметил, что когда я увеличиваю поля слева и справа от текста and
, тексты BLA-1
и BLA-2
обрезаются.
Есть ли лучший способ для этого?
Я думаю, что я не могу использовать относительный макет, так как я не смог бы, чтобы представления занимали эти размеры по экрану, верно?
UPDATE:
Также с моим подходом любой вид прокладки в TextViews отсекает текст
Проверьте мой ответ ниже, и дайте мне знать, если вы сталкиваетесь с каким-либо вопросом. –
Вы проверили мой ответ? это работает или нет? дайте мне знать, если вы столкнетесь с любым вопросом, сэр. –