Android RelativeLayout Проблема с различными размерами экрана - PullRequest
0 голосов
/ 07 ноября 2018
<?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"
    tools:context="com.testing.testinglibraryapps.Main2Activity">

<RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

    </RelativeLayout>
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

    </RelativeLayout>


</RelativeLayout>

Как разделить экран Android на две части. то есть одна Относительная компоновка должна быть на 3/4 части экрана, а другая должна иметь 1/4

Какие свойства я должен установить здесь для достижения желаемого макета

Ответы [ 2 ]

0 голосов
/ 07 ноября 2018

Этот пример может вам помочь.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    android:weightSum="4"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"

        >



    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"

        >



    </RelativeLayout>

</LinearLayout>
0 голосов
/ 07 ноября 2018

Вы можете сделать это так

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    android:weightSum="4"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:background="@android:color/holo_green_dark"
        >

        <!--Other Views Here-->

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@android:color/holo_red_dark"
        >

        <!--Other Views Here-->

    </RelativeLayout>

</LinearLayout>

Выход:

Output

...