Android 笔记一:线性布局

建立布局

新建项目后,在如图路径下新建xml文件可以开始编辑

weight的使用

android:layout_width="0dp",或android:layout_width="wrap_content"
之后在设置layout_weight即可


 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/LinearLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:background="#ADFF2F"
            android:layout_weight="1"/>


        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:background="#DA70D6"
            android:layout_weight="1"/>

    </LinearLayout>

效果如图:

android:layout_width="wrap_content"

同上

posted @ 2018-10-17 15:36  YuQiao0303  阅读(138)  评论(0编辑  收藏  举报