zoukankan      html  css  js  c++  java
  • Android相对布局(RelativeLayout)

    1,编写xml代码

    <?xml version="1.0" encoding="utf-8"?>
    <!--
    相对布局RelativeLayout
    -->
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <ImageView
            android:id="@+id/img"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:src="@drawable/img3"
            />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮"
            android:textSize="100dp"
    
            />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="右边1"
            android:textSize="100dp"
            android:textColor="@color/black"
            android:layout_toRightOf="@id/img"
            android:layout_alignTop="@id/img"
            android:layout_centerVertical="true"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="右边2"
            android:textSize="100dp"
            android:textColor="@color/black"
            android:layout_toRightOf="@id/img"
            android:layout_alignBottom="@id/img"
            android:layout_centerVertical="true"/>
    
         <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="上边"
            android:textSize="100dp"
            android:textColor="@color/black"
            android:layout_above="@id/img"
            android:layout_centerHorizontal="true"/>
         <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="下边"
            android:textSize="100dp"
            android:textColor="@color/black"
            android:layout_below="@id/img"
            android:layout_centerHorizontal="true"/>
         <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="左边1"
            android:textSize="100dp"
            android:textColor="@color/black"
            android:layout_toLeftOf="@id/img"
            android:layout_alignTop="@id/img"
            android:layout_centerVertical="true"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="左边2"
            android:textSize="100dp"
            android:textColor="@color/black"
            android:layout_toLeftOf="@id/img"
            android:layout_alignBottom="@id/img"
            android:layout_centerVertical="true"/>
    
    </RelativeLayout>
    

    2,运行结果截图

  • 相关阅读:
    EC600S连接阿里云
    纪念首次使用vscode+platformio完成点灯全过程
    使用EC600S-CN实现短信收发功能
    基于stm32,通过更换数据存储扇区提升w25q128flash芯片使用寿命
    0.96寸OLED模块-简述如何修改OLED_ShowChar()函数达到修改显示字体大小的目的
    stm32定时器初始化后自动进入一次中断问题
    个人PSP升级作业
    第一个微信小项目
    自己设计大学排名-数据库实践
    自己的第一个网页
  • 原文地址:https://www.cnblogs.com/d534/p/14808926.html
Copyright © 2011-2022 走看看