Date
May. 19th, 2024
 
2024年 4月 12日

Post: Android : Layout 基础

Android : Layout 基础

Published 12:07 Jul 12, 2014.

Created by @ezra. Categorized in #Programming, and tagged as #Android.

Source format: Markdown

Table of Content

好像一直都没有系统的写过 Android 方面的博客,就先从布局开始吧,介绍一些布局属性。

主要的布局方式有:

  • LinearLayout

  • RelativeLayout

  • FrameLayout: 帧布局,控件会一直叠加在一起

  • AbsoluteLayout: 很少使用,鉴于安卓设备的屏幕五花八门,并不推荐使用这种布局。

  • TableLayout: 同样很少用

常见的布局属性有:

  • android:layout_weight: 值为数字,表示权重

  • android:layout_above: 在某元素之上

  • android:layout_toLeftOf: 在某元素左边

  • android:layout_alignLeft: 依赖于某元素左边,平行对齐

  • android:layout_margin: 外边距

  • android:padding: 内边距

  • android:orientation: 子控件布局方向,可以设置垂直(vertical)或水平(horizontal)

  • android:visibility: 可见性,如果要隐藏则可设置为 goneinvisible,前者完全隐藏不占用空间,后者隐藏后仍占用空间

  • android:layout_widthandroid:layout_height: 宽和高,一般使用 wrap_contentmatch_parent

  • android:background: 背景

  • android:gravity: 重力属性,可设置 center_vertical

  • android:minHeight: 最小高度

  • android:layout_alignParentRight: 相对父控件

  • android:layout_toRightOf: 相对某控件右边

  • android:alighLeft: 控件左边与某控件左边平行

Pinned Message
HOTODOGO
I'm looking for a SOFTWARE PROJECT DIRECTOR / SOFTWARE R&D DIRECTOR position in a fresh and dynamic company. I would like to gain the right experience and extend my skills while working in great teams and big projects.
Feel free to contact me.
For more information, please view online résumé or download PDF
本人正在寻求任职 软件项目经理 / 软件技术经理 岗位的机会, 希望加⼊某个新鲜⽽充满活⼒的公司。
如有意向请随时 与我联系
更多信息请 查阅在线简历下载 PDF