zoukankan      html  css  js  c++  java
  • Android布局管理器

    Android中的布局包括
    :线性布局、表格布局、相对布局、帧布局和绝对布局;


    <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" > <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led2off" android:id="@+id/btnLED2Off" android:layout_weight="1" android:layout_alignParentRight="true" android:layout_marginLeft="10px" ></Button> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led1off" android:id="@+id/btnLED1Off" android:layout_weight="0.1" android:layout_toLeftOf="@id/btnLED2Off" ></Button> <Button android:layout_height="wrap_content" android:text="@string/led1on" android:layout_width="wrap_content" android:id="@+id/btnLED1On" android:layout_weight="1" android:layout_toLeftOf="@id/btnLED1Off" ></Button> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led2on" android:id="@+id/btnLED2On" android:layout_weight="1" android:layout_toLeftOf="@id/btnLED1On" android:layout_alignTop="@id/btnLED2Off" ></Button> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led3off" android:id="@+id/btnLED3Off" android:layout_weight="1" android:layout_below="@id/btnLED2Off" ></Button> <Button android:layout_height="wrap_content" android:text="@string/led3on" android:layout_width="wrap_content" android:id="@+id/btnLED3On" android:layout_weight="1" android:layout_below="@id/btnLED3Off" ></Button> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led4on" android:id="@+id/btnLED4On" android:layout_weight="1" android:layout_below="@id/btnLED3On" ></Button> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led4off" android:id="@+id/btnLED4Off" android:layout_weight="1" android:layout_below="@id/btnLED4On" ></Button> <!-- 我的注释--> <!--android:layout_alignParentTop="true"--> <!--android:layout_alignParentLeft="true"--> <!--android:layout_marginTop="295dp"--> </RelativeLayout>

    上面的代码就是界面布局的XML语句;

    主要是调整位置;

    </RelativeLayout>这个表示 相对布局;

    android:layout_width="wrap_content" //按钮大小适应字体大小
    android:layout_height="wrap_content"//按钮大小适应字体大小

    android:layout_alignParentRight="true" //靠在父窗口的最右边

    android:layout_toLeftOf="@id/btnLED2Off"//靠在按钮LED2OFF的左边

    android:layout_below="@id/btnLED2Off"//靠在按钮LED2OFF下边

    控件类:

    看来写博客确实耐心,我还是记录些代码吧:

     最后调整后的代码如下:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
        <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led2off" android:id="@+id/btnLED2Off"
                android:layout_weight="1" android:layout_alignParentRight="true"
                android:layout_marginLeft="10px"
        ></Button>
    
        <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led1off" android:id="@+id/btnLED1Off"
                android:layout_weight="0.1" android:layout_toLeftOf="@id/btnLED2Off"
                android:layout_marginLeft="10px"
        ></Button>
    
        <Button android:layout_height="wrap_content" android:text="@string/led1on" android:layout_width="wrap_content" android:id="@+id/btnLED1On"
                android:layout_weight="1" android:layout_toLeftOf="@id/btnLED1Off"
                android:layout_marginLeft="10px"
        ></Button>
    
        <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led2on" android:id="@+id/btnLED2On"
                android:layout_weight="1" android:layout_toLeftOf="@id/btnLED1On"
                android:layout_marginLeft="10px"
        ></Button>
    
    
        <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led3off" android:id="@+id/btnLED3Off"
                android:layout_weight="1" android:layout_below="@id/btnLED2Off"
                android:layout_alignParentRight="true"
                android:layout_marginLeft="10px"
        ></Button>
    
        <Button android:layout_height="wrap_content" android:text="@string/led3on" android:layout_width="wrap_content" android:id="@+id/btnLED3On"
                android:layout_weight="1"
                android:layout_toLeftOf="@id/btnLED3Off"
                android:layout_below="@id/btnLED2Off"
                android:layout_marginLeft="10px"
        ></Button>
    
        <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led4on" android:id="@+id/btnLED4On"
                android:layout_weight="1" android:layout_toLeftOf="@id/btnLED3On"
                android:layout_below="@id/btnLED1Off"
                android:layout_marginLeft="10px"
        ></Button>
    
        <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/led4off" android:id="@+id/btnLED4Off"
                android:layout_weight="1"
                android:layout_below="@id/btnLED2On"
                android:layout_toLeftOf="@id/btnLED4On"
        ></Button>
    
        <!-- 我的注释-->
        <!--android:layout_alignParentTop="true"-->
        <!--android:layout_alignParentLeft="true"-->
        <!--android:layout_marginTop="295dp"-->
    
    </RelativeLayout>
    
  • 相关阅读:
    设计模式-迭代器模式(Iterator)
    设计模式-责任链模式(responsibility)
    设计模式-中介者模式(Mediator)
    设计模式-解释器模式(Interpreter)
    设计模式-适配器模式(Adapter)
    第十章——维护索引(8)——在计算列中创建索引提高性能
    第十章——维护索引(7)——使用索引视图提高性能
    第十章——维护索引(6)——查找无用索引
    第十章——维护索引(5)——查找丢失索引
    第十章——维护索引(4)——通过重组索引提高性能
  • 原文地址:https://www.cnblogs.com/tao560532/p/3263791.html
Copyright © 2011-2022 走看看