Как показать цвета в горизонтальной разметке внутри контрплетки - PullRequest
0 голосов
/ 07 июля 2019

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

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

раскладка

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout   
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">   

    <Button       
        android:id="@+id/topBtn_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="topBtn1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toLeftOf="@id/topBtn_2"
        app:layout_constraintBottom_toTopOf="@id/fragmentContainer"
        android:onClick="clicksHandler"/>

    <Button
        android:id="@+id/topBtn_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="topBtn2"
        app:layout_constraintLeft_toRightOf="@id/topBtn_1"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toLeftOf="@id/topBtn_3"
        app:layout_constraintBottom_toTopOf="@id/fragmentContainer"
        android:onClick="clicksHandler"/>
     <Button
        android:id="@+id/topBtn_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="topBtn3"
        app:layout_constraintLeft_toRightOf="@id/topBtn_2"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toTopOf="@id/fragmentContainer"
        android:onClick="clicksHandler"/>  

    <LinearLayout
        android:id="@+id/fragmentContainer"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/topBtn_1"
        app:layout_constraintBottom_toTopOf="@id/BottomBtn_1">

        <FrameLayout
            android:id="@+id/fragOne"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_blue_light">
        </FrameLayout>

        <FrameLayout
            android:id="@+id/fragTwo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_orange_light">
        </FrameLayout>

    </LinearLayout>

    <Button
        android:id="@+id/BottomBtn_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="BottomBtn1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@id/BottomBtn_2"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/fragmentContainer"
        android:onClick="clicksHandler"/>

    <Button
        android:id="@+id/BottomBtn_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="BottomBtn2"
        app:layout_constraintLeft_toRightOf="@id/BottomBtn_1"
        app:layout_constraintRight_toLeftOf="@id/BottomBtn_3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/fragmentContainer"
        android:onClick="clicksHandler"/>
    <Button
        android:id="@+id/BottomBtn_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="BottomBtn3"
        app:layout_constraintLeft_toRightOf="@id/BottomBtn_2"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@id/fragmentContainer"
        android:onClick="clicksHandler"/>

</android.support.constraint.ConstraintLayout>

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