編寫代碼通過線性佈局實現以下UI界⾯,該佈局總共分爲上中下三部分,每⼀個部分展示的是⼀本書的 詳細信息

1.實現圖片

2.代碼

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="20dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical"
            >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="21dp"
                android:layout_weight="2"
                android:background="#7ba8b0">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="此處爲圖書封面"
                    android:textSize="20sp"></TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#baccde">

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4"
                >
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="書名"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#baccde">

            </LinearLayout>

        </LinearLayout>

        <!--中間顏色佈局-->
        <LinearLayout
            android:layout_width="3dp"
            android:layout_height="match_parent"
            android:background="#7489ab">

        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:orientation="vertical">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="概述"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#2e4d5c">

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="作者"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#2e4d5c">

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="日期"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#2e4d5c">

            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="20dp"
        android:layout_weight="1"
        android:background="#7ba8b0">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical"
            >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="21dp"
                android:layout_weight="2"
                android:background="#7ba8b0">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="此處爲圖書封面"
                    android:textSize="20sp"></TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#baccde">

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4"
                >
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="書名"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#baccde">

            </LinearLayout>

        </LinearLayout>

        <!--中間顏色佈局-->
        <LinearLayout
            android:layout_width="3dp"
            android:layout_height="match_parent"
            android:background="#7489ab">

        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:orientation="vertical">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="概述"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#2e4d5c">

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="作者"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#2e4d5c">

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="日期"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#2e4d5c">

            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="20dp"
        android:layout_weight="1"
        android:background="#7ba8b0">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical"
            >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="21dp"
                android:layout_weight="2"
                android:background="#7ba8b0">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="此處爲圖書封面"
                    android:textSize="20sp"></TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#baccde">

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4"
                >
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="書名"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#baccde">

            </LinearLayout>

        </LinearLayout>

        <!--中間顏色佈局-->
        <LinearLayout
            android:layout_width="3dp"
            android:layout_height="match_parent"
            android:background="#7489ab">

        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:orientation="vertical">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="概述"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#2e4d5c">

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="作者"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#2e4d5c">

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:background="#bfd9d4">
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="日期"
                    android:textSize="20sp">

                </TextView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="10dp"
                android:background="#2e4d5c">

            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

3.感覺

明明很簡單,但是確非常耗時。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章