zoukankan      html  css  js  c++  java
  • Android的开始之相对布局

    第一层相对布局,,第二层嵌套线性或相对

    相对布局不加权重

    android:paddingLeft="30px":按钮上设置的内容(例如图片)离按钮左边边界30个像素//内边距

    android:layout_marginLeft="30px":整个按钮离左边设置的内容30个像素

    Android:layout_above="@id/xxx"  --将控件置于给定ID控件之上
    android:layout_below="@id/xxx"  --将控件置于给定ID控件之下

    android:layout_toLeftOf="@id/xxx"  --将控件的右边缘和给定ID控件的左边缘对齐
    android:layout_toRightOf="@id/xxx"  --将控件的左边缘和给定ID控件的右边缘对齐

    android:layout_alignLeft="@id/xxx"  --将控件的左边缘和给定ID控件的左边缘对齐
    android:layout_alignTop="@id/xxx"  --将控件的上边缘和给定ID控件的上边缘对齐
    android:layout_alignRight="@id/xxx"  --将控件的右边缘和给定ID控件的右边缘对齐
    android:layout_alignBottom="@id/xxx"  --将控件的底边缘和给定ID控件的底边缘对齐
    android:layout_alignParentLeft="true"  --将控件的左边缘和父控件的左边缘对齐
    android:layout_alignParentTop="true"  --将控件的上边缘和父控件的上边缘对齐
    android:layout_alignParentRight="true"  --将控件的右边缘和父控件的右边缘对齐
    android:layout_alignParentBottom="true" --将控件的底边缘和父控件的底边缘对齐
    android:layout_centerInParent="true"  --将控件置于父控件的中心位置
    android:layout_centerHorizontal="true"  --将控件置于水平方向的中心位置
    android:layout_centerVertical="true"  --将控件置于垂直方向的中心位置

    example:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.relative_layout.MainActivity$PlaceholderFragment" >

    <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="20dp"
    android:text="Button1" />

    <Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button2"
    android:layout_marginLeft="15dp"
    android:layout_marginTop="46dp"
    android:layout_toRightOf="@+id/button2"
    android:text="Button3" />

    <Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button1"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="34dp"
    android:text="Button2" />

    <Button
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/button2"
    android:layout_alignRight="@+id/button3"
    android:text="Button4" />

    <Button
    android:id="@+id/button5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/button1"
    android:layout_alignTop="@+id/button3"
    android:text="Button5" />

    </RelativeLayout>

  • 相关阅读:
    【计算机网络】宽带、基带传输
    【操作系统】多道程序的理解
    【操作系统】操作系统的理解
    NLP学习常用的网页链接
    linux下常用FTP命令 1. 连接ftp服务器[转]
    shell运行java/Jar 脚本
    jsp验证码
    用javascript实现的验证码
    eclipse设置高亮显示的颜色
    oracle 导出
  • 原文地址:https://www.cnblogs.com/my334420/p/6435729.html
Copyright © 2011-2022 走看看