Android开发编码规范之适配规则(四)

Android开发编码规范之适配规则(四)

1.适配布局

1.1采用比例布局方式

<android.support.percent.PercentRelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/llyt_all"
    >
    <!--年级-->
    <android.support.percent.PercentRelativeLayout
        android:id="@+id/pc_rl"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@drawable/bg_line"
        android:orientation="vertical"
        app:layout_heightPercent="46%"
        app:layout_marginLeftPercent="3.88%"
        app:layout_marginRightPercent="3.88%"
        app:layout_marginTopPercent="3.5%"
        app:layout_widthPercent="100%">

        <LinearLayout
            android:id="@+id/pc_ll1"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:gravity="center"
            app:layout_heightPercent="18%"
            app:layout_widthPercent="100%">

            <TextView
                android:id="@+id/tv_book"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/main_tv_book"
                android:textColor="@color/black_gray"
                android:textSize="16sp" />

        </LinearLayout>

        <android.support.percent.PercentRelativeLayout
            android:id="@+id/pc_rl1"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_below="@+id/pc_ll1"
            app:layout_heightPercent="47%"
            app:layout_marginTopPercent="3.2%"
            app:layout_widthPercent="100%">

            <android.support.percent.PercentRelativeLayout
                android:id="@+id/pc_rl2"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_heightPercent="100%"
                app:layout_widthPercent="50%">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/main_tv_residue"
                    android:textColor="@color/black_gray_dark"
                    android:textSize="13sp"
                    app:layout_marginLeftPercent="35%" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:orientation="horizontal"
                    app:layout_marginTopPercent="28%">

                    <TextView
                        android:id="@+id/tv_remainday"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/main_tv_remainday"
                        android:textColor="@color/black_gray"
                        android:textSize="40sp" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="bottom"
                        android:layout_marginBottom="4dp"
                        android:text="@string/main_tv_day"
                        android:textColor="@color/black_gray"
                        android:textSize="13sp" />
                </LinearLayout>

                <TextView
                    android:id="@+id/tv_practice"
                    android:layout_width="90dp"
                    android:layout_height="28dp"
                    android:layout_alignParentBottom="true"
                    android:background="@drawable/bg_rectangle"
                    android:gravity="center"
                    android:text="@string/main_tv_practice"
                    android:textColor="#f9b500"
                    android:textSize="13sp"
                    app:layout_marginLeftPercent="16%" />
            </android.support.percent.PercentRelativeLayout>

            <android.support.percent.PercentRelativeLayout
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_alignParentRight="true"
                app:layout_heightPercent="100%"
                app:layout_widthPercent="50%">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:text="@string/main_tv_todaybackword"
                    android:textColor="@color/black_gray_dark"
                    android:textSize="13sp"
                    app:layout_marginRightPercent="33%" />

                <TextView
                    android:id="@+id/tv_tadayword"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:text="@string/main_tv_tv_todayword"
                    android:textColor="#fde6a9"
                    android:textSize="40sp"
                    app:layout_marginTopPercent="28%" />

                <TextView
                    android:id="@+id/tv_plan"
                    android:layout_width="90dp"
                    android:layout_height="28dp"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:background="@drawable/bg_rectangle"
                    android:gravity="center"
                    android:text="@string/main_tv_plan"
                    android:textColor="#f9b500"
                    android:textSize="13sp"
                    app:layout_marginRightPercent="20%" />
            </android.support.percent.PercentRelativeLayout>
        </android.support.percent.PercentRelativeLayout>

        <android.support.percent.PercentRelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/pc_rl1"
            android:orientation="vertical"
            android:paddingLeft="15dp"
            android:paddingRight="15dp"
            app:layout_marginTopPercent="12%">

            <LinearLayout
                android:id="@+id/pc_ll2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/main_thiscomple"
                    android:textColor="@color/black_gray"
                    android:textSize="16sp" />

                <TextView
                    android:id="@+id/tv_undone"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dp"
                    android:text="@string/main_tv_undone"
                    android:textColor="#31aaff"
                    android:textSize="16sp" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/main_slash"
                    android:textColor="#31aaff"
                    android:textSize="16sp" />

                <TextView
                    android:id="@+id/tv_comple"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/main_tv_complete"
                    android:textColor="@color/black_gray"
                    android:textSize="16sp" />
            </LinearLayout>

            <com.eaglesoul.eplatform.english.ui.widget.ProgressView
                android:id="@+id/progress"
                android:layout_width="match_parent"
                android:layout_height="9dp"
                android:layout_below="@+id/pc_ll2"
                android:layout_marginTop="10dp"
                app:layout_marginTopPercent="10%" />
        </android.support.percent.PercentRelativeLayout>
    </android.support.percent.PercentRelativeLayout>


    <android.support.percent.PercentRelativeLayout
        android:id="@+id/pc_rl3"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_below="@+id/pc_rl"
        app:layout_heightPercent="28%"
        app:layout_marginLeftPercent="4.2%"
        app:layout_marginRightPercent="4.2%"
        app:layout_marginTopPercent="2.8%">

        <com.eaglesoul.eplatform.english.ui.widget.MainImageView
            android:id="@+id/ibtn_study"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:background="@drawable/bt_study2"
            android:scaleType="centerInside"
            app:layout_heightPercent="100%"
            app:layout_widthPercent="47%" />

        <com.eaglesoul.eplatform.english.ui.widget.MainImageView
            android:id="@+id/ibtn_analysis"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_alignParentRight="true"
            android:background="@drawable/bt_analysis2"
            android:scaleType="centerInside"
            app:layout_heightPercent="100%"
            app:layout_widthPercent="47%" />
    </android.support.percent.PercentRelativeLayout>

    <FrameLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@+id/pc_rl3"
        app:layout_heightPercent="100%"
        app:layout_marginBottomPercent="1.4%"
        app:layout_marginLeftPercent="3.8%"
        app:layout_marginRightPercent="3.8%"
        app:layout_marginTopPercent="2.2%"
        app:layout_widthPercent="100%">

        <com.eaglesoul.eplatform.english.ui.widget.MainImageView
            android:id="@+id/ibtn_pk"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="center"
            android:background="@drawable/bt_pk3"
            android:src="@drawable/bt_pk2" />
    </FrameLayout>

</android.support.percent.PercentRelativeLayout>

1.2加入可以滑动的控件进行布局,例如RecyclerView ScrollView等可滑动空间

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值