Два вертикальных линейных макета и хотят, чтобы один шире другого - PullRequest
0 голосов
/ 23 мая 2018

У меня есть макет, который является относительной, который содержит 2 вертикальных линейных макета.Каждый из линейных макетов использует равную ширину.Ориентация горизонтальная, и я хотел бы, чтобы первая линейная схема использовала 2/3 от макета, а вторая - от 1/3.Я не очень хорошо разбираюсь в XML.Я работал в Visual Basic и теперь перехожу на Java с помощью Android Studio.

Вот XML-код для макета действия.

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 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"
        android:layout_weight="3"
        android:background="@color/colorBackgroundGray"
        tools:layout="@layout/fragment_select_item"
        tools:context="com.myCompany.myProduct.activities.ReturnAreaActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"

        >
        <FrameLayout
            android:id="@+id/FragmentFrame"
            android:layout_width="match_parent"
            android:layout_height="match_parent">


        </FrameLayout>
        <include
            android:id="@+id/include2"
            layout="@layout/frm1"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_gravity="left"
            android:layout_weight="1.7" />



    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:paddingLeft="5dp"
        android:orientation="vertical">

        <include
            android:id="@+id/include"
            layout="@layout/layout_numpad5"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginStart="220dp"
            android:layout_weight="1.3"
            android:layout_gravity="right"
            />

    </LinearLayout>



</RelativeLayout>

Вес - это то, что я только что попробовал.Есть идеи?enter image description here

1 Ответ

0 голосов
/ 23 мая 2018

Попробуйте ниже базовую логику, она будет работать нормально в вашем случае

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="2">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="First Linear Layout"
        android:gravity="center"/>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Second Linear Layout"
        android:gravity="center"/>

</LinearLayout>

</LinearLayout>

Выход:

enter image description here

Чтобы изменить ориентацию (если вы не хотите размещать макеты рядом), просто измените значение или android: ориентация = "вертикальный" на android: ориентация = "горизонтальный".

ВЫХОД:

enter image description here

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