一、盒模型

我买了一盒月饼,月饼盒算是一个父容器,那月饼这个控件,距离月饼盒的边距是多少呢,这里就需要用到margin

margin是指从自身边框到另一个容器边框之间的距离,就是容器外距离。(外边距)

 

具体到android中的属性:

android:layout_marginLeft="20dp"

android:layout_marginTop="15dp

...

 

二、对齐方式

相对父控件的对齐方式,是对着左边还是右边还是中间呢

 

具体到安卓中的属性:

android:layout_gravity=“center"

...

事实证明,只要有父容器,无论是布局还是控件都可以用

 

 

三、填充

padding是指自身边框到自身内部另一个容器边框之间的距离,就是容器内距离。(内边距)

比如月饼印了一个花纹,月饼这个控件的花纹距离月饼的边是多少,就是padding了 

 

具体到安卓中的属性:

android:gravity=“bottom"

 

 

四、一个小例子

 

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    tools:context=".MainActivity">

 

    <RadioGroup

        android:id="@+id/radioGroup"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:orientation="horizontal"

        android:layout_gravity="center"

        android:layout_marginTop="150dp"

        >

 

        <RadioButton

            android:id="@+id/btnMan"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="男"

            android:checked="true"/>

 

        <RadioButton

            android:id="@+id/btnWoman"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="女"/>

 

    RadioGroup>

LinearLayout>

 

更多相关文章

  1. Android 虚拟摇杆,多种模式回调,返回距离级别,方向,角度。
  2. Android学习笔记4之容器
  3. android 页面容器 下一页很上一页view
  4. [android]布局(容器)简介和使用方法
  5. Android——TabHost(标签容器)相关知识总结贴
  6. Android获取RecyclerView滑动距离
  7. android中求区域内两个坐标之间的距离的实现
  8. Android布局容器
  9. 通话距离感应实现源码

随机推荐

  1. Android--应用开发2(AndroidManfest.xml)
  2. Belkin adds WeMo Light switch, looks t
  3. Android Training精要(二)開啟ActionBar的O
  4. Android 权限相关问题
  5. android屏幕适配
  6. Android常用秘籍总结
  7. Android Activity savedInstanceState
  8. Android NDK学习 Android.mk实例和NDK实
  9. 移动开发:Android数据连接浅析
  10. Android(安卓)SQLITE 操作工具类