19软件工程Android常用布局
16lz
2021-12-04
Android常用布局
环境问题
先把gradle.zip下载下来
放在这个目录
C:\Users\Administrator.gradle\wrapper\dists\gradle-6.5-bin\6nifqtx7604sqp1q6g8wikw7p
6nifqtx7604sqp1q6g8wikw7p每个人不一样
遇到问题 去百度
线性布局
1 方向
android:orientation=“vertical”
2.子组件重心
android:gravity=“center_horizontal|bottom”
格式化代码
菜单 --code–reformat code
快捷键 CTRL+SHIFT+L
颜色
#F00 三位16进制 分别代表红绿蓝
#FF0000 六位 每两位代表一种颜色
#FFFF0000 八位 最前面两位代表透明度
在res color.xml中定义一种颜色 之后使用@color/name
使用安装系统定好的颜色
-如果是水平方向 注意子组件的宽度不要写成match_parent
-如果是垂直方向 注意子组件的高度不要写成match_parent
<?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"> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#33FF0000" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="#FF0000"/> <TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="#00FF00"/> <TextView android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent" android:background="#0000FF"/> LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#330000FF" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#FF0000"/> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#00FF00"/> <TextView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#0000FF"/> LinearLayout>LinearLayout>
相对布局
1、三个center
水平 android:layout_centerHorizontal="true" 垂直 android:layout_centerVertical="true" 居中 android:layout_centerInParent="true"
2、对齐
3、对齐和居中进行组合
更多相关文章
- Android架构组件(1)Lifecycles体系
- android RadioButton文字居中的方法
- Android编程中的常见小问题ZZ
- ImageView设置图片大小
- android 自定义数字软键盘
- ImageView的属性
- Android简单图片浏览器
- http://www.eoeandroid.com/blog-546380-2248.html
- [Android]Android(安卓)颜色大全 colors.xml