线性布局的重要属性 (LinearLayout)

相关属性链接

layout_width 和 layout_height是布局器相对于外部构件的一个宽高距离。

layout_margin是指与外部控件的整个边缘距离。

padding是指与控件的内边距离

android:orientation 方向作用于整个布局中的所有控件

android:layout_weight 权重,布局中的控件在布局中所占的比例,需要在控件中设置

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal"android:layout_width="match_parent"android:layout_height="match_parent"><!--vertical:垂直的    horizontal:水平的--><!--layout_weight:权重--><!--android:layout_margin="20dp"android:padding="20dp"--><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:text="慕课慕课慕课慕课慕课慕课慕课"android:background="#ff0000"android:layout_weight="1"android:textSize="28sp"android:layout_gravity="bottom"/><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:text="慕课"android:background="#00ff00"android:layout_weight="2"android:textSize="28sp"android:layout_gravity="center"/><TextViewandroid:layout_width="0dp"android:layout_height="wrap_content"android:text="慕课"android:background="#0000ff"android:layout_weight="2"android:textSize="28sp"/></LinearLayout>

相对布局的重要属性 (RelativeLayou)

相对布局相关常用属性

<?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"><!--android:layout_centerInParentandroid:layout_alignParentLeftandroid:layout_alignParentRightandroid:layout_alignParentTopandroid:layout_alignParentBottomandroid:layout_centerHorizontalandroid:layout_centerVertical--><TextViewandroid:id="@+id/center"android:layout_width="100dp"android:layout_height="100dp"android:textSize="30sp"android:text="屏幕正中"android:background="#ff0000"android:layout_centerInParent="true"/><!--1.在参照物的某边android:layout_toLeftOfandroid:layout_toRightOfandroid:layout_aboveandroid:layout_below2.和参照物的某边线对齐android:layout_alignTopandroid:layout_alignBottomandroid:layout_alignLeftandroid:layout_alignRight--><TextViewandroid:layout_width="100dp"android:layout_height="100dp"android:textSize="30sp"android:text="中偏左上"android:background="#00ff00"android:layout_above="@id/center"android:layout_toLeftOf="@id/center"/><TextViewandroid:layout_width="100dp"android:layout_height="100dp"android:textSize="30sp"android:text="中偏右上"android:background="#00ff00"android:layout_above="@id/center"android:layout_toRightOf="@id/center"/><TextViewandroid:layout_width="100dp"android:layout_height="100dp"android:textSize="30sp"android:text="中偏左下"android:background="#00ff00"android:layout_below="@id/center"android:layout_toLeftOf="@id/center"/><TextViewandroid:layout_width="100dp"android:layout_height="100dp"android:textSize="30sp"android:text="中偏右下"android:background="#00ff00"android:layout_below="@id/center"android:layout_toRightOf="@id/center"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="和中间上边线对齐"android:background="#0000ff"android:layout_alignRight="@id/center"/></RelativeLayout>

帧布局的重要属性(FrameLayout)

android:foreground

设置帧布局前景图像(始终在所有子控件之上)

android:foreground Gravity

设置前景图像显示位置

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"tools:context="com.example.layoutdemo.FrameActivity"android:foreground="@mipmap/ic_launcher"android:foregroundGravity="center"><TextViewandroid:layout_width="350dp"android:layout_height="350dp"android:background="#ff0000"android:layout_gravity="center"/><TextViewandroid:layout_width="300dp"android:layout_height="300dp"android:background="#00ff00"android:layout_gravity="center" /><TextViewandroid:layout_width="250dp"android:layout_height="250dp"android:background="#0000ff"android:layout_gravity="center" /><TextViewandroid:layout_width="200dp"android:layout_height="200dp"android:background="#00ffff"android:layout_gravity="center" /><TextViewandroid:layout_width="150dp"android:layout_height="150dp"android:background="#ff00ff"android:layout_gravity="center" /><TextViewandroid:layout_width="100dp"android:layout_height="100dp"android:background="#ffff00"android:layout_gravity="center"android:text="黄色的文本"android:gravity="center"/>
</FrameLayout>

表格布局的重要属性(TableLayout)

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:collapseColumns="0,1"><!--android:stretchColumns="1,2"    设置可伸展的列android:shrinkColumns="1,2"    设置可收缩的列android:collapseColumns="0,1"     设置可隐藏的列如果直接在TableLayout中添加控件,那么控件将和父容器等宽如果想让控件出现在同一行,那么这些控件的外层一定要加一对<TableRow>在TableRow中的控件,宽度都是默认wrap_content--><EditText /><TableRow><Buttonandroid:text="7777777777777777777"/><Buttonandroid:id="@+id/button"android:text="8" /><Buttonandroid:text="9"/><Buttonandroid:text="/"/></TableRow><TableRow><Button android:text="4"/><Button android:text="5"/><Button android:text="6"/><Button android:text="*"/></TableRow><TableRow><Button android:text="1"/><Button android:text="2"/><Button android:text="3"/><Button android:text="-"/></TableRow><TableRow><Button android:text="0"/><Button android:text="."/><Button android:text="+"/><Button android:text="="/></TableRow><Button android:text="clear"/>
</TableLayout>

网格布局的重要属性(GirdLayout)

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="wrap_content"android:rowCount="5"android:columnCount="4"><Button android:text="1"/><Button android:text="2"/><Button android:text="3"/><Button android:text="/"/><Button android:text="4"/><Button android:text="5" /><Button android:text="6"/><Button android:text="*"/><Button android:text="7"/><Button android:text="8"/><Button android:text="9"/><Button android:text="-"/><Button android:text="0"android:layout_columnSpan="2"android:layout_gravity="fill"/><Button android:text="."/><Button android:text="+"android:layout_rowSpan="2"android:layout_gravity="fill"/><Button android:text="="android:layout_columnSpan="3"android:layout_gravity="fill"/>
</GridLayout>

约束布局的重要属性

【安卓开发 】Android初级开发(零)各种布局相关推荐

  1. Android初级开发笔记-- activity启动模式的学习(1)

    第一次学习Android中一个很重要的概念,启动模式.文章记录的也只是一些入门知识,随着学习的深入还会有activity启动模式的学习(2)和(3). 下面分三个小点说一下对启动模式的理解区别以及如何 ...

  2. 安卓(Android)开发百度语音唤醒(识别)

    安卓(Android)开发百度语音唤醒(识别) 目录 安卓(Android)开发百度语音唤醒(识别) 一:准备 1:获取自定义唤醒词 2:SDK下载 3:将bdasr_V3_xxx_xxx.jar引入 ...

  3. 安卓(android)开发应该怎么学?需要哪些基础知识?

    随着智能手机的流行,现在很多大大小小的开发商都需要在手机上具备客户端,这里是一片强大的吸金磁场,那么很多想学习android的朋友,都会有个疑问,那就是:安卓(android)应该怎么学,需要哪些基础 ...

  4. 移动端app开发-03-IOS 初级开发入门教程

    移动端app开发-03-IOS 初级开发入门教程 什么是iOS   iOS是苹果公司为它的移动设备(iPhone.iPad.iWatch等)开发的移动操作系统. iOS发展史 2007年苹果发布iPh ...

  5. 用java开发一个简单的安卓程序,Android NDK开发简单程序分享(Hello Word!)

    在之前的博客中已经为大家介绍了,如何在win环境下配置DNK程序,本篇我将带大家实现一个简单的Hello jni程序,让大家真正感受一下NDK开发的魅力.这里我们选择使用C+JAVA开发Android ...

  6. 音乐应用开发Android应用开发--MP3音乐播放器界面设计(2)

    在写这篇文章之前,xxx已写过了几篇关于改音乐应用开发主题的文章,想要了解的朋友可以去翻一下之前的文章 Android应用开发--MP3音乐播放器界面计划(2) 2013年5月25日 简.美音乐播放器 ...

  7. Android游戏开发Android软件开发【教程三十篇】

    Android软件开发之发送短信与系统短信库解析(三十)  New Android软件开发之获取通讯录联系人信息(二十九)  New Android软件开发之PreferenceActivity中的组 ...

  8. VS2019 C++的跨平台开发——Android .so开发

    这篇介绍下怎么用VS开发Android使用的.so动态链接库文件. Android环境配置 1.先打开VS installer ​ 2.选中C++移动开发​ 3.如果VS没有下载NDK和SDK的,需要 ...

  9. android 计步器 开发,Android计步器开发

    本文只赘述Android计步器开发里计步的原理. 在Android4.4版本之后,新增了STEP_COUNTER和STEP_DECTECTOR STEP_COUNTER表示自从开机以来,你走的步数累计 ...

最新文章

  1. FutureWarning: Passing (type, 1) or ‘1type‘ it will be understood as (type, (1,)) / ‘(1,)type‘
  2. Android 使用Application类保存应用的全局数据
  3. 【转载】iOS堆和栈的理解
  4. jQuery ajax发送POST、JS url跳转、console用法
  5. 女生转行IT与男生有什么不一样?
  6. 操作对象_DOM进阶——HTML属性操作(对象属性)
  7. macosx 不允许无名信号量_信号量限流,高并发场景不得不说的秘密
  8. Spark MLlib之K-Means聚类算法
  9. 一加8 Pro或将配备120Hz刷新率屏幕
  10. java查询出来的日期类型_Java的第29天,Oracle函数
  11. numpy—np.random.multivariate_normal
  12. ENVI5.4 新增图像分类介绍
  13. linux find内容替换,利用find和sed批量替换文件内容
  14. 网络安全系列之培训笔记整理
  15. word文档页码不连续怎么弄
  16. 判断二极管导通例题_如何判断开关电源变压器的好坏
  17. BitTorrent 原理简介
  18. Minecraft 1.18.1、1.18.2模组开发 21.传送门(Portal)
  19. H263H264MPEG4
  20. 使用turtle库,绘制一个正方形。

热门文章

  1. ajax 示例_通过示例了解挥发
  2. Java 11新字符串方法的基准
  3. Java中的异步等待
  4. flatMap()与concatMap()与concatMapEager()– RxJava常见问题解答
  5. 为@Cacheable设置TTL – Spring
  6. junit rule_使用JUnit的ExpectedException和@Rule测试自定义异常
  7. 在Kafka中发布订阅模型
  8. ejb jsf jpa_完整的WebApplication JSF EJB JPA JAAS –第2部分
  9. cks子,间谍,局部Mo子和短管
  10. 9针串口定义测试方法_一些定义–测试技术9