Android макет более линейных - PullRequest
       1

Android макет более линейных

1 голос
/ 08 декабря 2011

Я хочу создать макет, как на изображении

3 зеленых макета - это линейные макеты, и код показан ниже.Кто-нибудь может дать мне код для других красных раскладок над этими тремя зелеными.Какой тип макета должен быть?

enter image description here

    <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">


        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="1">

            </LinearLayout>
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="1">

            </LinearLayout>
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="1">

            </LinearLayout>

 </LinearLayout>

Спасибо

Ответы [ 3 ]

2 голосов
/ 08 декабря 2011

Вы хотите поместить все свои перекрывающиеся макеты в относительный макет. Поэтому для воссоздания чего-то похожего на вашу фотографию сделайте:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="#00ff00"
            android:layout_marginRight="10dp" >
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="#00ff00"
            android:layout_marginRight="10dp" >
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:background="#00ff00"
            android:layout_marginRight="10dp" >
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="#ff0000"
            android:orientation="vertical"
            android:layout_marginTop="200dp" 
            android:layout_marginRight="50dp">
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="#ff0000"
            android:orientation="vertical"
            android:layout_marginTop="200dp" 
            android:layout_marginRight="50dp">
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>
1 голос
/ 08 декабря 2011

RelativeLayout обычно используется для наложения других макетов. В этом случае вы можете поместить свой LinearLayouts в RelativeLayout, а затем добавить два других макета соответственно в качестве дочерних элементов родителя RelativeLayout.

Пример:

<RelativeLayout
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
    <LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="1">
        </LinearLayout>
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="1">
        </LinearLayout>
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_weight="1">
        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="50dp"
        android:layout_marginTop="100dp"
        android:layout_alignParentLeft="true">
    </LinearLayout>
    <LinearLayout
        android:layout_width="250dp"
        android:layout_height="50dp"
        android:layout_marginTop="200dp"
        android:layout_alignParentLeft="true">
    </LinearLayout>
</RelativeLayout>

Существует множество других атрибутов, которые вы можете применить к дочерним элементам, на которые RelativeLayout будет отвечать, но, похоже, они не относятся к тому, о чем вы просили.

0 голосов
/ 08 декабря 2011

Вы можете использовать RelativeLayout в верхней части всей иерархии макета. Первым макетом в нем будет линейный макет, в котором будет весь относительный макет. Кроме того, вы можете поместить другие макеты, которые будут размещены рядом в соответствующем макете. Вы можете выровнять их по своему усмотрению с привязкой в ​​соответствии с родителями или в соответствии друг с другом. удачи

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