Android Studio Linear Layout Design проблема - PullRequest
0 голосов
/ 05 сентября 2018

У меня проблема с разработкой Android Studio Layout для приложения. В линейном макете я хочу добавить первые два макета в первом столбце по горизонтали, а затем в следующем столбце, я хочу добавить, что три кнопки по горизонтали и, наконец, в последнем столбце хотят добавить ListView. Любая помощь будет высоко оценен. Как и сейчас, все попадает в один ряд.

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical" >


         <james.view.VideoView
               android:id="@+id/remoteVideoView"
              android:layout_width="120dp"
             android:layout_height="90dp"
              />

        <james.view.VideoView
               android:id="@+id/localVideoView"
              android:layout_width="120dp"
              android:layout_height="90dp"
             />

             <Button
             android:id="@+id/startVideoButton"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="Start Call"
              />

             <Button
              android:id="@+id/stopVideoButton"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="End Call"
             />

             <Button
             android:id="@+id/sendmessage"
                 android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="msg"
             />


             <ListView
             android:id="@+id/errorList"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

        </ListView>
    </LinearLayout>

</android.support.constraint.ConstraintLayou

Вот как я хочу, чтобы мой макет был

Ответы [ 3 ]

0 голосов
/ 05 сентября 2018

Это образец xml, похожий на ваше изображение. Поскольку в вашем коде используется constraintLayout, я создал xml с использованием constraintLayout вместо линейного макета. Я создал это с экрана дизайна, а не с экрана текста. Это xml `

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

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="49dp"
        android:layout_marginStart="49dp"
        android:layout_marginTop="32dp"
        android:text="Button"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="67dp"
        android:layout_marginRight="67dp"
        android:layout_marginTop="32dp"
        android:text="Button"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="193dp"
        android:text="Button"
        app:layout_constraintEnd_toEndOf="@+id/button"
        app:layout_constraintStart_toStartOf="@+id/button"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="29dp"
        android:layout_marginStart="29dp"
        android:text="Button"
        app:layout_constraintBaseline_toBaselineOf="@+id/button3"
        app:layout_constraintStart_toEndOf="@+id/button3" />

    <Button
        android:id="@+id/button5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="35dp"
        android:layout_marginEnd="17dp"
        android:layout_marginRight="17dp"
        android:layout_marginTop="193dp"
        android:text="Button"
        app:layout_constraintBottom_toTopOf="@+id/recyclerView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="19dp"
        android:layout_marginEnd="22dp"
        android:layout_marginLeft="22dp"
        android:layout_marginRight="22dp"
        android:layout_marginStart="22dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button5" />
</android.support.constraint.ConstraintLayout>

` Пожалуйста, посмотрите, поможет ли это вам. Это не точный экран в соответствии с вашими требованиями.

0 голосов
/ 05 сентября 2018

Если вы не понимаете ограничений. Вы можете использовать обычную LinearLayout.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    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"
    android:orientation="vertical"
    android:padding="10dp"
    tools:context=".MainActivity"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="90dp"
        >

        <james.view.VideoView
            android:id="@+id/remoteVideoView"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            />

        <james.view.VideoView
            android:id="@+id/localVideoView"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            />

    </LinearLayout>

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

        <Button
            android:id="@+id/startVideoButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Start Call"/>

        <Button
            android:id="@+id/stopVideoButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="End Call"/>

        <Button
            android:id="@+id/sendmessage"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="msg"/>

    </LinearLayout>

    <ListView
        android:id="@+id/errorList"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="10dp"
        android:layout_weight="1"
        >

    </ListView>

</LinearLayout>

Довольно просто!

0 голосов
/ 05 сентября 2018

Решение:

Это именно то, что вы хотите, просто скопируйте и вставьте свою работу:

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/linearLayout2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <james.view.VideoView
            android:id="@+id/remoteVideoView"
            android:layout_width="120dp"
            android:layout_height="90dp"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="8dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/localVideoView"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <james.view.VideoView
            android:id="@+id/localVideoView"
            android:layout_width="120dp"
            android:layout_height="90dp"
            android:layout_marginBottom="8dp"
            android:layout_marginTop="8dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toEndOf="@+id/remoteVideoView"
            app:layout_constraintTop_toTopOf="parent" />

    </android.support.constraint.ConstraintLayout>

    <LinearLayout
        android:id="@+id/linearLayout3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/linearLayout2">

        <Button
            android:id="@+id/startVideoButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Start Call" />

        <Button
            android:id="@+id/stopVideoButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="End Call" />

        <Button
            android:id="@+id/sendmessage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="msg" />

    </LinearLayout>


    <ListView
        android:id="@+id/errorList"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginEnd="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/linearLayout3">

    </ListView>

</android.support.constraint.ConstraintLayout>

Попробуй. Надеюсь, это поможет.

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