• Android(java)学习笔记107:Relativelayout相对布局


    1. 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:id="@+id/bt_middle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="中间" />
    
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@id/bt_middle"
            android:layout_centerHorizontal="true"
            android:text="↑" />
    
        <Button
            android:id="@+id/bt_down"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/bt_middle"
            android:layout_centerHorizontal="true"
            android:text="↓" />
    
        <Button
            android:id="@+id/bt_left"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@id/bt_middle"
            android:text="←" />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@id/bt_middle"
            android:text="→" />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/bt_left"
            android:layout_toLeftOf="@id/bt_down"
            android:text="↙" />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/button1"
            android:layout_alignBottom="@+id/button1"
            android:layout_toRightOf="@+id/button1"
            android:text="↗" />
    
    </RelativeLayout>

    布局效果图:

  • 相关阅读:
    数据库学习笔记01 Mariadb安装配置
    数据库学习笔记02 SQL 增删改查
    EF oral study notes 02 level 12~13
    Python编程学习基础笔记10
    EF oral study notes 01 level 10~11
    Linux基础操作命令
    20201318李兴昕第11章学习笔记
    20201318李兴昕第九章学习笔记
    20201318李兴昕第七、八章学习笔记
    20201318李兴昕第十章学习笔记
  • 原文地址:https://www.cnblogs.com/hebao0514/p/4733772.html
Copyright © 2020-2023  润新知