Android XML布局:我们如何制作像Duolingo应用程序这样的XML布局

Android XML布局:我们如何制作像Duolingo应用程序这样的XML布局,android,android-layout,Android,Android Layout,我是Android的初学者。因此,我想知道如何实现图中这样的xml布局 这是您想要的代码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:

我是Android的初学者。因此,我想知道如何实现图中这样的xml布局


这是您想要的代码

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

    <LinearLayout
        android:background="@color/colorAccent"
        android:orientation="vertical"
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </LinearLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_weight="0.3"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

        </LinearLayout>
        <LinearLayout
            android:orientation="vertical"
            android:layout_weight="0.2"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

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

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

                </LinearLayout>

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

                </LinearLayout>


            </LinearLayout>

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

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

                </LinearLayout>

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

                </LinearLayout>

            </LinearLayout>

        </LinearLayout>


    </LinearLayout>

    <LinearLayout
        android:background="#795548"
        android:orientation="vertical"
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </LinearLayout>
</LinearLayout>


只要将整个代码复制到xml文件中,您就会知道。。并根据您的要求进行更改。现在,您可以在特定布局中添加textview、imageview、button和其他内容。这都是关于布局权重属性的。。试着理解我的代码。如果你只知道一行一行地写每个布局,你就会知道它是如何工作的。

你试过什么?我自己没有试过,因为我不知道从哪里开始。我一直在使用FrameLayout和Relativelayout之间徘徊。非常感谢您给我带来的麻烦。是的,我非常理解。您已经使用了嵌套的线性布局。太好了,你能给我推荐一些很酷的字体,我可以免费下载并在我的Android项目中使用吗?roboto没有很酷的字体。这是谷歌字体。最好的。。每个n每个棒棒糖和更高的设备都有这种字体。