zoukankan      html  css  js  c++  java
  • 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>

    布局效果图:

  • 相关阅读:
    IE8下网页中的视频会遮挡住顶层DIV的解决办法
    Synchronized 偏向锁、轻量级锁、自旋锁、锁消除
    Lock的使用
    Synchronized与ReentrantLock区别总结(简单粗暴,一目了然)
    Java线程池 面试题(精简)
    Java 线程池的认识和使用
    bat等大公司常考java多线程面试题
    Java面试题必备知识之ThreadLocal
    阿里面试题
    Spring中Bean的生命周期
  • 原文地址:https://www.cnblogs.com/hebao0514/p/4733772.html
Copyright © 2011-2022 走看看