Как разделить просмотры по горизонтали равными во вложенных представлениях

<View
    android:layout_width = "match_parent"
    android:layout_height = "1dp"
    android:background = "@android:color/darker_gray"/>

Я пробовал приведенный выше код, но ничего не делал, также пытался изменить высоту на другое значение, и при использовании вышеуказанного кода предварительный просмотр кода перестает отображаться. Есть ли для этого хороший виджет. Я действительно не хочу использовать изображение, так как было бы сложно сопоставить с ним другие компоненты. И я хочу, чтобы это было относительно позиционировано. Спасибо Вот изображение предварительного просмотра кода ниже https://i.stack.imgur.com/GD7Ro.png

<?xml version = "1.0" encoding = "utf-8"?>

<RelativeLayout 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">

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

        <LinearLayout
            android:layout_width = "match_parent"
            android:layout_height = "match_parent"
            android:layout_weight = "1"
            android:orientation = "vertical"
            tools:context = ".MainActivity">


            <TextView
                android:layout_width = "wrap_content"
                android:layout_height = "wrap_content"
                android:layout_gravity = "center"
                android:layout_marginBottom = "12dp"
                android:layout_marginTop = "12dp"
                android:text = "Team A"
                android:textSize = "24sp" />

            <TextView
                android:id = "@+id/points"
                android:layout_width = "wrap_content"
                android:layout_height = "wrap_content"
                android:layout_gravity = "center"
                android:layout_marginBottom = "12dp"
                android:text = "0"
                android:textSize = "24sp" />

            <Button
                android:layout_width = "match_parent"
                android:layout_height = "wrap_content"
                android:layout_marginLeft = "8dp"
                android:layout_marginRight = "8dp"
                android:onClick = "on3p"
                android:text = "+3 Points" />

            <Button
                android:layout_width = "match_parent"
                android:layout_height = "wrap_content"
                android:layout_marginLeft = "8dp"
                android:layout_marginTop = "12dp"
                android:onClick = "on2p"
                android:text = "+2 Points" />

            <Button
                android:layout_width = "match_parent"
                android:layout_height = "wrap_content"
                android:layout_marginLeft = "8dp"
                android:layout_marginRight = "8dp"
                android:layout_marginTop = "12dp"
                android:onClick = "on1p"
                android:text = "Free Throw" />

        </LinearLayout>

        <LinearLayout
            android:layout_width = "match_parent"
            android:layout_height = "match_parent"
            android:layout_weight = "1"
            android:orientation = "vertical"
            tools:context = ".MainActivity">


            <TextView
                android:layout_width = "wrap_content"
                android:layout_height = "wrap_content"
                android:layout_gravity = "center"
                android:layout_marginBottom = "12dp"
                android:layout_marginTop = "12dp"
                android:text = "Team B"
                android:textSize = "24sp" />

            <TextView
                android:id = "@+id/points2"
                android:layout_width = "wrap_content"
                android:layout_height = "wrap_content"
                android:layout_gravity = "center"
                android:layout_marginBottom = "12dp"
                android:text = "0"
                android:textSize = "24sp" />

            <Button
                android:layout_width = "match_parent"
                android:layout_height = "wrap_content"
                android:layout_marginLeft = "8dp"
                android:layout_marginRight = "8dp"
                android:onClick = "on3pb"
                android:text = "+3 Points" />

            <Button
                android:layout_width = "match_parent"
                android:layout_height = "wrap_content"
                android:layout_marginLeft = "8dp"
                android:layout_marginRight = "8dp"
                android:layout_marginTop = "12dp"
                android:onClick = "on2pb"
                android:text = "+2 Points" />

            <Button
                android:layout_width = "match_parent"
                android:layout_height = "wrap_content"
                android:layout_marginLeft = "8dp"
                android:layout_marginRight = "8dp"
                android:layout_marginTop = "12dp"
                android:onClick = "on1pb"
                android:text = "Free Throw" />

        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:layout_width = "match_parent"
        android:layout_height = "match_parent">

        <Button
            android:text = "Reset"
            android:layout_width = "wrap_content"
            android:layout_height = "wrap_content"
            android:layout_gravity = "bottom"
            android:layout_marginLeft = "150dp"
            android:layout_marginBottom = "20dp"
            android:onClick = "rst"/>


    </LinearLayout>
</RelativeLayout>

Не могли бы вы объяснить поподробнее, чего именно вы пытаетесь достичь? Вы также можете отобразить изображение прямо в теле вашего вопроса, используя маленький значок над областью редактирования вопроса. Просто отредактируйте свой вопрос и постарайтесь не оставлять комментарии к собственному вопросу. Спасибо и удачи!

sɐunıɔןɐqɐp 10.06.2018 13:13
1
1
17
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий
<RelativeLayout>
    <linearLayout>
        <LinearLayout>
        </LinearLayout>
                <View
                    android:layout_width = "match_parent"
                    android:layout_height = "1dp"
                    android:background = "@android:color/darker_gray"/>
        <LinearLayout>
        </LinearLayout>
     </LinearLayout>
</RelativeLayout>

Другие вопросы по теме