android开发之四种基本布局
来源:互联网 发布:手机淘宝查看卖家电话 编辑:程序博客网 时间:2024/06/01 03:57
1.LinerLayout
又称线性布局
特有属性:
layout_weight按照比例指定控件大小
2.RelativeLayout
又称相对布局
常用属性:
<ImageView android:id="@+id/imageViews" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:src="@drawable/advance"/> <TextView android:id="@+id/text_views" android:layout_width="wrap_content" android:layout_gravity="right" android:layout_height="wrap_content" android:text="This is textView"/> <EditText android:id="@+id/editText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:hint="请输入" /> <Button android:id="@+id/Button_5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@id/editText" android:layout_above="@id/editText" android:text="button 500" /> <Button android:id="@+id/Button_9" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/editText" android:layout_above="@id/editText" android:text="button 900" /> <Button android:id="@+id/Button_6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@id/editText" android:layout_below="@id/editText" android:text="button 600" /> <Button android:id="@+id/Button_7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/editText" android:layout_below="@id/editText" android:text="button 700" />
3.FrameLayout
又称帧布局,用的不多,不多赘述
4.百分比布局
属于新增布局,只为FrameLayout与RelativeLayout进行功能扩展,提供了PercentFrameLayout和PercentRelativeLayout 两个全新布局,辅助FrameLayout与RelativeLayout
<?xml version="1.0" encoding="utf-8"?><android.support.percent.PercentFrameLayout 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" tools:context="com.example.sandwind.onedemo.FiveActivity"> <Button android:id="@+id/button1" android:text="button1" android:layout_gravity="left|top" app:layout_widthPercent="50%" app:layout_heightPercent="50%"/> <Button android:id="@+id/button2" android:text="button2" android:layout_gravity="right|top" app:layout_widthPercent="50%" app:layout_heightPercent="50%"/> <Button android:id="@+id/button3" android:text="button3" android:layout_gravity="left|bottom" app:layout_widthPercent="50%" app:layout_heightPercent="50%"/> <Button android:id="@+id/button4" android:text="button4" android:layout_gravity="right|bottom" app:layout_widthPercent="50%" app:layout_heightPercent="50%"/></android.support.percent.PercentFrameLayout>
小结:只是扩展
gravity:指定文字在控件中的对齐方式
layout_gravity:指定控件在布局中的对齐方式
dp:用于指定控件大小及间距
sp:文字大小单位
阅读全文
0 0
- android开发之四种基本布局
- android开发之四种基本布局和自定义控件
- android四种基本布局之LinearLayout
- android四种基本布局之RelativeLayout
- android四种基本布局之FrameLayoutAndTableLayout
- Android之四种基本布局
- Android开发之基本控件和详解四种布局方式
- android-四种基本布局
- Android四种基本布局
- Android, 四种基本布局
- 【Android】四种基本布局
- Android四种基本布局
- Android四种基本布局
- Android 开发实践 常用控件 四种基本布局
- Android开发之路四-------布局
- Android 中的四种基本布局
- 详解Android四种基本布局
- [android]_[四种基本布局]
- SpringBoot+Mybatis 完整实例 增删查改
- [日常训练] 单词
- poj Stall Reservations(贪心)
- 从零开始开发一款Android App
- vi 常用命令
- android开发之四种基本布局
- Service基础
- 扫码微信开发中的一些事
- window.open详解
- php 支持断点续传的文件下载类
- Android新特性介绍,ConstraintLayout完全解析
- Java编译后产生class文件的命名规则
- C++Primer拾遗
- 一道让你轻松搞定Java面向对象方法