zoukankan      html  css  js  c++  java
  • 【Android】1.布局

    LinearLayout

    Linearlayout

    例程效果如下

       <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:weightSum="2">
    
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:layout_weight="1"
                android:text="button1"
                />
    
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="right|center_vertical"
                android:text="button2"
                android:visibility="invisible"
                />
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="button3"
                />
        </LinearLayout>
    

    效果图

    RelativeLayout

    RelativeLayout

    例程效果如下

    <?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:layout_centerHorizontal="true"
            android:text="进攻"
            />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:text="左勾拳"
            />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"
            android:text="右勾拳"
            />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            android:text="防守"
            />
    
        <Button
            android:id="@+id/btn_juezhao"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerInParent="true"
            android:text="究极带大招"
            />
    
        <!--左上对齐-->
        <Button
            android:id="@+id/btn_zuo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@id/btn_juezhao"
            android:layout_alignTop="@id/btn_juezhao"
            android:text=""
            />
        <!--上中对齐-->
        <Button
        android:id="@+id/btn_shang"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/btn_juezhao"
        android:layout_centerHorizontal="true"
        android:text=""
        />      
        <!--右上对齐-->
        <Button
            android:id="@+id/btn_you"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/btn_juezhao" 
            android:layout_alignTop="@id/btn_juezhao"
            android:text=""
            />
        <!--下中对齐-->
        <Button
            android:id="@+id/btn_xia"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/btn_juezhao"
            android:layout_centerHorizontal="true"
            android:text=""
            />
        
    </RelativeLayout>
    

    在这里插入图片描述

  • 相关阅读:
    数据结构与算法之PHP实现二叉树的遍历
    数据结构与算法之二叉树的基本概念和类型
    聚集索引,非聚集索引,覆盖索引 原理
    Vue学习笔记:methods、computed、watch的区别
    xsl 和xml transform方法的调用
    Chrome , Firfox 不支持fireEvent的方法
    分布式存储
    firefox并不支持selectSingleNode和selectNodes的解决方法
    503 Service Unavailable
    处理【由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面】
  • 原文地址:https://www.cnblogs.com/SiriusZHT/p/14310808.html
Copyright © 2011-2022 走看看