个人作业一每日总结3.10

 个人作业一每日总结

  今日收获:

 Android中有六大布局,分别是: LinearLayout(线性布局),RelativeLayout(相对布局),TableLayout(表格布局) FrameLayout(帧布局),AbsoluteLayout(绝对布局),GridLayout(网格布局)

实现代码:

<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="2"/>   

       

</LinearLayout> 

 

  遇到问题:

  要实现第一个的1:1的效果,只需要分别把两个LinearLayout的weight改成1和1就可以了 用法归纳: 按比例划分水平方向:将涉及到的View的android:width属性设置为0dp,然后设置为android weight属性设置比例即可;类推,竖直方向,只需设android:height为0dp,然后设weight属性即可!

 

posted on 2021-03-10 06:21  风中明月  阅读(32)  评论(0编辑  收藏  举报