# AndroidTutorial **Repository Path**: mazaiting/AndroidTutorial ## Basic Information - **Project Name**: AndroidTutorial - **Description**: Android 教程 - **Primary Language**: Kotlin - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-11-29 - **Last Updated**: 2024-03-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AndroidDemo #### 介绍 android 模块代码示例 #### 安装教程 1. Android Studio 2021.1.1 2. SDK: Android 12 3. Tomcat 9 4. Nox 模拟器 #### 使用说明 - activity_life_cycle - 生命周期 - 状态保存 - Java 单元测试 - 国际化 - Toast 使用 - Menu 使用 - Intent 使用 - [registerForActivityResult](https://blog.csdn.net/jingzz1/article/details/107338872/) - 启动模式 - View - TextView id、text、gravity(对齐方式)、textSize、textColor - Button id、text、textAllCaps(禁止大写转换) - EditText id、text、hint(提示信息)、maxLines(最大行数) - ImageView id、src - ProgressBar id、visibility、style(?android:attr/progressBarStyleHorizontal)、max - AlertDialog - [RecyclerView详解](resources/RecyclerView详解.pdf) - WebView - [基本用法](resources/WebView_基本用法.pdf) - [代码交互](resources/WebView_代码交互.pdf) - [性能优化](resources/WebView_性能优化.pdf) - 自定义 View - [自定义View之组合控件](resources/自定义View之组合控件.pdf) - [自定义View之继承控件](resources/自定义View之继承控件.pdf) - [自定义View之自绘控件](resources/自定义View之自绘控件.pdf) - layout - LinearLayout(线性布局) orientation(方向)、layout_gravity(重心)、layout_weight(权重) - RelativeLayout(相对布局) layout_alignxxx、toxxxof - FrameLayout(帧布局) layout_gravity(重心) - ConstraintLayout(约束布局) 详情见[ConstraintLayout详解](resources/ConstraintLayout详解.pdf) ​ - fragment - android:name - replace - addToBackStack 返回栈 - 生命周期 - broadcast_receiver - 注册方式 - 动态注册 - 静态注册 - 发送广播 - 无序广播 - 有序广播 - 本地广播 - data - 文件 - SharedPreferences - [SQLite](https://www.runoob.com/sqlite/sqlite-tutorial.html) - sqlite3 工具 ```bash # 进入命令行 adb shell # 进入数据库 cd /data/data/<包名>/databases # 打开数据库 sqlite3 *.db # 查看所有表 .table # 查看建表语句 .schema ``` - content_provider - 操作联系人 - 自定义 ContentProvider - provider - 为操作app模块中ContentProvider提供的数据进行增删改查 ​ - media - 通知 - 音频 - 视频 - network - GetRequest GET 请求 - PostRequest POST 请求 - UploadRequest 单文件上传 - MultiUploadRequest 多文件上传 - XML解析 - JSON解析 - service - 线程 - 普通服务 - 绑定服务 - 其他服务 - [view_material](https://m3.material.io/components/top-app-bar/implementation/android)- [Material组件](https://github.com/material-components/material-components-android) - [Toolbar](https://m3.material.io/components/top-app-bar/implementation) - [NavigationDrawer](https://m3.material.io/components/navigation-drawer/implementation) - [Button](https://m3.material.io/components/all-buttons) - [Elevated button](https://m3.material.io/m3/pages/common-buttons/guidelines/#4e89da4d-a8fa-4e20-bb8d-b8a93eff3e3e) - [Filled button](https://m3.material.io/m3/pages/common-buttons/guidelines/#9ecffdb3-ef29-47e7-8d5d-f78b404fcafe) - [Filled tonal button](https://m3.material.io/m3/pages/common-buttons/guidelines/#07a1577b-aaf5-4824-a698-03526421058b) - [Outlined button](https://m3.material.io/m3/pages/common-buttons/guidelines/#3742b09f-c224-43e0-a83e-541bd29d0f05) - [Text button](https://m3.material.io/m3/pages/common-buttons/guidelines/#c9bcbc0b-ee05-45ad-8e80-e814ae919fbb) - [Floating action button (FAB)](https://m3.material.io/m3/pages/fab/overview/) - [Extended FAB](https://m3.material.io/m3/pages/extended-fab/) - [SnakeBar](https://material.io/components/snackbars/android) - [Cards](https://m3.material.io/components/cards/implementation) - [AppBarBottom](https://material.io/components/app-bars-bottom/android) - [SwipeRefreshLayout](https://developer.android.google.cn/jetpack/androidx/releases/swiperefreshlayout?hl=zh-cn) - [Dialog](https://m3.material.io/components/dialogs/) - [Menu](https://m3.material.io/components/menus) #### Size Of Picture - 屏幕大小 | Name | description | | :----: | :--------------------: | | Small | 提供小屏幕设备的资源 | | normal | 提供中等屏幕设备的资源 | | large | 提供大屏幕设备的资源 | | xlarge | 提供超大屏幕设备的资源 | - 屏幕方向 | Name | description | | :--: | :------------------: | | land | 提供给横屏设备的资源 | | port | 提供给竖屏设备的资源 | - Dpi, resolution and icon size relationship | Name | Resolution | Boot Icon Size | | :-----------------: | :---------: | :------------: | | L DPI ( 120 DPI ) | 240*320px | 36 x 36 px | | M DPI (160 DPI ) | 320*480px | 48 x 48 px | | H DPI ( 240 DPI ) | 480*800px | 72 x 72 px | | XH DPI ( 320 DPI ) | 1280*720px | 96 x 96 px | | XXH DPI( 480 DPI ) | 1920*1080px | 144 x 144 px | | XXXH DPI( 640 DPI ) | 3840*2160px | 192 x 192 px | - PX to DP | Name | DPI | Proportion (based on mdpi 1) | Conversion relationship with px | | :-----: | :-----: | :--------------------------: | :-----------------------------: | | lpdi | 120 DPI | 0.75 | 1 dp = 0.75 px | | mdpi | 160 DPI | 1 | 1 dp = 1 px | | hdpi | 240 DPI | 1.5 | 1 dp = 1.5 px | | xhdpi | 320 DPI | 2 | 1 dp = 2 px | | xxhdpi | 480 DPI | 3 | 1 dp = 3 px | | xxxhdpi | 640 DPI | 4 | 1 dp = 4 px | #### 其他 ##### 创建图标 模块右键 -> New -> Vector Asset, 选择对应图标即可 ##### 上传文件到模拟器 ```bash adb push 本地路径 模拟器路径 ``` ##### 下载文件到本地 ```bash adb pull 模拟器路径 本地路径 ``` #### 参与贡献 1. [简书](https://www.jianshu.com/u/5d2cb4bfeb15) 2. [码云](https://gitee.com/) 3. 邮箱: zaitingma@foxmail.com 4. [新浪微博](http://blog.sina.com.cn/mazaiting)