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>
    

    在这里插入图片描述

  • 相关阅读:
    python3 基本使用多线程
    img前置显示屏装load图片
    leetcode
    亲串 (hdu 2203 KMP)
    基于VC面部识别软件(识别出人脸特征)
    IT该忍者神龟Oracle 树操作(select…start with…connect by…prior)
    It&#39;s about trust
    hdu 2128 Frog(简单DP)
    第四十天 阿乐在其中—Android小游戏的飞机(四)加入敌人
    Mac OS X通过结合80port
  • 原文地址:https://www.cnblogs.com/SiriusZHT/p/14310808.html
Copyright © 2011-2022 走看看