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

  • 相关阅读:
    Js事件触发列表与解说(转)
    HTTP 头部解释,HTTP 头部详细分析,最全HTTP头部信息
    【转】php 数组 编码转换
    Cookie 的规范介绍
    PHP底层的运行机制与原理
    PHP为什么会被认为是草根语言?
    asp.net中读取带有加号(+)的Cookie,会自动把加号替换为空格
    git克隆某个分支到本地指定的目录中
    yq(json,yaml)格式转换工具安装和使用
    k8s中configmap的作用及使用方式
  • 原文地址:https://www.cnblogs.com/bilibiliganbei/p/5414638.html
Copyright © 2011-2022 走看看