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、对齐和居中进行组合


更多相关文章

  1. Android架构组件(1)Lifecycles体系
  2. android RadioButton文字居中的方法
  3. Android编程中的常见小问题ZZ
  4. ImageView设置图片大小
  5. android 自定义数字软键盘
  6. ImageView的属性
  7. Android简单图片浏览器
  8. http://www.eoeandroid.com/blog-546380-2248.html
  9. [Android]Android(安卓)颜色大全 colors.xml

随机推荐

  1. 针对文件转移情况的Android SDK离线安装
  2. Android使用ant对项目进行编译签名优化打
  3. 一起Talk Android吧(第二百六十四回:Androi
  4. Android瀑布流优化,解决Recyclerview展示
  5. Android NDK 开发教程八:Box2D 的Android
  6. Android和Python之间的不能说的小秘密
  7. 谷安: 该打针吃药啦:新的 Android 恶意应
  8. 阿里面试官:关于RecyclerView做下分享
  9. [来自异次元] 选择适合自己的 Android (
  10. Android(安卓)应用程序基础