zoukankan      html  css  js  c++  java
  • 相对布局和网格布局

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:layout_alignParentLeft="true"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:layout_alignParentRight="true"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:layout_centerInParent="true"
            android:id="@+id/bt_center"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:layout_centerHorizontal="true"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:layout_centerVertical="true"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"/>
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="新按钮"
            android:layout_alignBottom="@id/bt_center"
            android:layout_toLeftOf="@id/bt_center"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="新按钮"
            android:layout_alignTop="@id/bt_center"
            android:layout_toRightOf="@id/bt_center"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="新按钮"
            android:layout_above="@id/bt_center"
            android:layout_alignLeft="@id/bt_center"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="新按钮"
            android:layout_below="@id/bt_center"
            android:layout_alignRight="@id/bt_center"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="新按钮"
            android:layout_below="@id/bt_center"
            android:layout_toLeftOf="@id/bt_center"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="新按钮"
            android:layout_below="@id/bt_center"
            android:layout_toRightOf="@id/bt_center"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="新按钮"
            android:layout_above="@id/bt_center"
            android:layout_toRightOf="@id/bt_center"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="新按钮"
            android:layout_above="@id/bt_center"
            android:layout_toLeftOf="@id/bt_center"/>
    
    </RelativeLayout>
    View Code

    <?xml version="1.0" encoding="utf-8"?>
    <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:rowCount="3"
        android:columnCount="4"
        android:padding="10dp">
    
        <Button
            android:text="按钮1"
            android:layout_row="0"
            android:layout_column="1"
            android:layout_columnSpan="1"
            android:layout_gravity="fill"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"/>
        <Button
            android:text="按钮2"
            android:layout_row="0"
            android:layout_column="0"
            android:layout_rowSpan="1"
            android:layout_gravity="fill"
            android:layout_columnWeight="1"/>
        <Button
            android:layout_gravity="fill"
            android:text="按钮3"
            android:layout_columnWeight="1"/>
        <Button
            android:layout_gravity="fill"
            android:text="按钮4"
            android:layout_columnWeight="1"/>
        <Button
            android:layout_gravity="fill"
            android:text="按钮5"
            android:layout_columnWeight="1"
            android:layout_rowWeight="1"/>
        <Button
            android:layout_gravity="fill"
            android:text="按钮6"
            android:layout_columnWeight="1"/>
        <Button
            android:layout_gravity="fill"
            android:text="按钮7"
            android:layout_columnWeight="1"/>
        <Button
            android:layout_gravity="fill"
            android:text="按钮8"
            android:layout_columnWeight="1"/>
    
    </GridLayout>
    View Code

  • 相关阅读:
    利用JavaScript制作网页中“选项卡”效果。 (二)
    Threading and UI
    我不太喜欢的一篇文章: [真爱无言]
    坚持,习惯,自然
    6行代码实现无组建上传(转)
    【转帖】20个你未必知道的CSS技巧
    CSS Filter 代替 图片 实现 渐变背景效果。
    Microsoft Excelに...
    ATM机的故事
    利用JavaScript制作网页中“选项卡”效果。 (三)——终极应用 JavaScript tabifier
  • 原文地址:https://www.cnblogs.com/bilibiliganbei/p/5414638.html
Copyright © 2011-2022 走看看