(七)Android布局类型(网格布局GridLayout)

2024-03-18 00:04

本文主要是介绍(七)Android布局类型(网格布局GridLayout),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

从表格布局中可以了解到,无法实现跨行。网格布局不仅能实现跨行、还能实现跨列,并且,该种布局能自动进行子元素的定位,在使用上,更加灵活。

知识点1:设置最大行数和最大列数

最大行数设置(假设为2):android:rowCount="2"
最大列数设置(假设为4):android:columnCount="4"

案例1:设置最大行数和最大列数(但是无法限制组件个数)

<?xml version="1.0" encoding="utf-8"?>
<GridLayout 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"android:rowCount="2"android:columnCount="4"tools:context=".MainActivity"><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮1"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮2"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮3"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮4"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮5"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮6"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮7"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮8"/>
</GridLayout>

从结果中可以看出,右方的布局中,看起来好像是有3行似的,前两行的右侧也没有填满

注意:设置最大行数为2,最大列数为4,并不表示只能放置8个组件,还是可以多增加组件的

刚刚说到,“该种布局能自动进行子元素的定位”,也就是说,刚刚的行数为2,列数为4,如果只放8个组件,那么就是2行4列。如果想要把组件排列为4行2列,则只需要修改代码为:

android:rowCount="4"
android:columnCount="2"

知识点2:实现跨列

核心代码:

设置跨列(假设跨2列):android:layout_columnSpan="2"

此时发现,按钮1并没有横跨按钮2的位置;按钮2空出来了,把按钮8挤到了下一行。

此时需要做两件事:1)实现跨列;2)按钮8的位置不能动

设置横向填充(具体设置代码如下),按钮1占了按钮2的位置,他们两个组件是水平方向上相邻组件,所以设置横向填充,使得按钮1不仅占据自己的位置,还要占据被跨列的位置。

android:layout_gravity="fill_horizontal"

由于按钮1占据了按钮2的位置,所有的组件都往后移了一位,导致按钮8也出现了移位。既然按钮2被按钮1占了,那么,按钮2就不应该再存在。所以,解决方法有两个,要么删除按钮2,要么注释掉按钮2。下图展示的是注释掉按钮2。

完整代码:

<?xml version="1.0" encoding="utf-8"?>
<GridLayout 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"android:rowCount="2"android:columnCount="4"tools:context=".MainActivity"><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnSpan="2"android:layout_gravity="fill_horizontal"android:text="按钮1"/>
<!--    <Button android:layout_width="wrap_content"-->
<!--        android:layout_height="wrap_content"-->
<!--        android:text="按钮2"/>--><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮3"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮4"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮5"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮6"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮7"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮8"/>
</GridLayout>

知识点3:实现跨行

按照跨列的思路,跨行的实现基本思路是:1)设置跨行;2)设置占满;3)将被占的组件注释掉。

1)设置跨行

android:layout_rowSpan="2"

2)设置占满

注意,由于按钮3占用的是按钮7的位置,它们两个组件是垂直关系,所以设置占满方式,要选用垂直占满。

核心代码:

android:layout_gravity="fill_vertical"

 3)3)将被占的组件注释掉,由于占用的是按钮7,所以应该注释掉按钮7对应的代码

此时发现,按钮3确实占了按钮7的位置,目的是达到了,但是高度超出了两个按钮,这是因为网格布局的高度设置为填满父容器(android:layout_height="match_parent") 

所以,将父容器的高度填满方式改为根据内容进行填充(wrap_content),那么两个按钮的高度就是网格布局的高度。

整体代码:

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="wrap_content"android:rowCount="2"android:columnCount="4"tools:context=".MainActivity"><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnSpan="2"android:layout_gravity="fill_horizontal"android:text="按钮1"/>
<!--    <Button android:layout_width="wrap_content"-->
<!--        android:layout_height="wrap_content"-->
<!--        android:text="按钮2"/>--><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_rowSpan="2"android:layout_gravity="fill_vertical"android:text="按钮3"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮4"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮5"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮6"/>
<!--    <Button android:layout_width="wrap_content"-->
<!--        android:layout_height="wrap_content"-->
<!--        android:text="按钮7"/>--><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮8"/>
</GridLayout>

进阶 

首先设置2行4列的排版

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="wrap_content"android:rowCount="2"android:columnCount="4"tools:context=".MainActivity"><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮1"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮2"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮3"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮4"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮5"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮6"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮7"/><Button android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="按钮8"/>
</GridLayout>

 

实现水平均分铺满排版

原谅:手动绘制四个水平均分的按钮,很难绘制准确。大家看上图的时候,务必把四个蓝色组件框看成是一样大小的,每个宽度占红色宽度的1/4

思路:1)水平铺满,则网格布局的宽度要设置为占满父容器;2)其次,每个按钮要均分宽度,那么宽度就是不知道的,所以设置为0dp,并且还要告诉每个组件所占相等。

第一步:设置网格布局的宽度要设置为占满父容器

第二步:设置组件宽度为0dp,占比相等

核心代码:

android:layout_width="0dp"
android:layout_columnWeight="1"

注意:设置的是列占比权重相等,水平方向上均分列,看起来水平方向上每个组件宽度相等。

完整代码:

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="wrap_content"android:rowCount="2"android:columnCount="4"tools:context=".MainActivity"><Button android:layout_width="0dp"android:layout_columnWeight="1"android:layout_height="wrap_content"android:text="按钮1"/><Button android:layout_width="0dp"android:layout_columnWeight="1"android:layout_height="wrap_content"android:text="按钮2"/><Button android:layout_width="0dp"android:layout_columnWeight="1"android:layout_height="wrap_content"android:text="按钮3"/><Button android:layout_width="0dp"android:layout_columnWeight="1"android:layout_height="wrap_content"android:text="按钮4"/><Button android:layout_width="0dp"android:layout_columnWeight="1"android:layout_height="wrap_content"android:text="按钮5"/><Button android:layout_width="0dp"android:layout_columnWeight="1"android:layout_height="wrap_content"android:text="按钮6"/><Button android:layout_width="0dp"android:layout_columnWeight="1"android:layout_height="wrap_content"android:text="按钮7"/><Button android:layout_width="0dp"android:layout_columnWeight="1"android:layout_height="wrap_content"android:text="按钮8"/>
</GridLayout>

实现垂直均分铺满排版

希望的结果是:

当然,如果每列都设置为垂直均分,那么,每列效果都应该和第一列效果一致。

思路:1)垂直铺满,则网格布局的高度要设置为占满父容器;2)其次,每个按钮要均分宽度,那么高度就是不知道的,所以设置为0dp,并且还要告诉每个组件所占相等。

核心代码:

 android:layout_height="0dp"android:layout_rowWeight="1"

1)垂直铺满,则网格布局的高度要设置为占满父容器

第二步:设置组件高度为0dp,占比相等

android:layout_height="0dp"
android:layout_rowWeight="1"

完整代码:

 

<?xml version="1.0" encoding="utf-8"?>
<GridLayout 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"android:rowCount="2"android:columnCount="4"tools:context=".MainActivity"><Button android:layout_width="wrap_content"android:layout_height="0dp"android:layout_rowWeight="1"android:text="按钮1"/><Button android:layout_width="wrap_content"android:layout_height="0dp"android:layout_rowWeight="1"android:text="按钮2"/><Button android:layout_width="wrap_content"android:layout_height="0dp"android:layout_rowWeight="1"android:text="按钮3"/><Button android:layout_width="wrap_content"android:layout_height="0dp"android:layout_rowWeight="1"android:text="按钮4"/><Button android:layout_width="wrap_content"android:layout_height="0dp"android:layout_rowWeight="1"android:text="按钮5"/><Button android:layout_width="wrap_content"android:layout_height="0dp"android:layout_rowWeight="1"android:text="按钮6"/><Button android:layout_width="wrap_content"android:layout_height="0dp"android:layout_rowWeight="1"android:text="按钮7"/><Button android:layout_width="wrap_content"android:layout_height="0dp"android:layout_rowWeight="1"android:text="按钮8"/>
</GridLayout>

实现全屏均分铺满排版

 根据上述两个案例的学习,可以发现,水平均分则垂直方向出现空白,垂直均分,则右侧出现空白

要实现垂直和水平方向都实现均分,则将两则融合起来即可。

思路:1)网格布局的宽高均要填充满父容器;2)设置宽高均为0dp,列和行上的占比均相等

核心代码:

android:layout_width="0dp"
android:height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"

完整代码和效果

<?xml version="1.0" encoding="utf-8"?>
<GridLayout 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"android:rowCount="2"android:columnCount="4"tools:context=".MainActivity"><Button android:layout_width="0dp"android:height="0dp"android:layout_rowWeight="1"android:layout_columnWeight="1"android:text="按钮1"/><Button android:layout_width="0dp"android:height="0dp"android:layout_rowWeight="1"android:layout_columnWeight="1"android:text="按钮2"/><Button android:layout_width="0dp"android:height="0dp"android:layout_rowWeight="1"android:layout_columnWeight="1"android:text="按钮3"/><Button android:layout_width="0dp"android:height="0dp"android:layout_rowWeight="1"android:layout_columnWeight="1"android:text="按钮4"/><Button android:layout_width="0dp"android:height="0dp"android:layout_rowWeight="1"android:layout_columnWeight="1"android:text="按钮5"/><Button android:layout_width="0dp"android:height="0dp"android:layout_rowWeight="1"android:layout_columnWeight="1"android:text="按钮6"/><Button android:layout_width="0dp"android:height="0dp"android:layout_rowWeight="1"android:layout_columnWeight="1"android:text="按钮7"/><Button android:layout_width="0dp"android:height="0dp"android:layout_rowWeight="1"android:layout_columnWeight="1"android:text="按钮8"/>
</GridLayout>

测试1:你真的学会了吗?试试吧 

目标:设计如下界面

参考代码:

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:rowCount="6"android:columnCount="4"android:useDefaultMargins="true"><EditText android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="3"android:layout_columnSpan="3"android:hint="0"android:gravity="right"android:background="@null"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:gravity="center"android:text="/"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="1"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="2"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="3"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="*"/><!--第3行--><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="4"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="5"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="6"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="-"/><!--第4行--><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="7"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="8"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="9"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:layout_rowSpan="3"android:layout_gravity="fill"android:gravity="center"android:text="+"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:text="0"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:layout_columnSpan="2"android:text="00"/><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:layout_columnSpan="3"android:text="="/>
</GridLayout>

相信排版是没有问题的,但是和效果图一模一样,还是需要进行精细化处理

1)由于底部有空白,所以高度不可能是占满,可以选择根据内容自动设置高度

2)其次,组件之间有间隔,可以使用默认的外边距

综合核心代码是:

android:layout_height="wrap_content"
android:useDefaultMargins="true"

3)然后是第一个组件,特点是占据了3列,所以不仅要设置跨列,还要设置占比为其他组件的3倍;文字右对齐;如果使用的是编辑框,则会出现下划线,这个下划线需要去掉

综合核心代码是:

android:layout_columnWeight="3"
android:layout_columnSpan="3"
android:gravity="right"
android:background="@null"

4) 其他组件依次排列,实现跨行和跨列即可

测试2:你真的学会了吗?把界面放大试试

参考代码:

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:rowCount="6"android:columnCount="4"android:useDefaultMargins="true"><EditTextandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_columnSpan="3"android:layout_columnWeight="3"android:layout_rowWeight="1"android:layout_gravity="fill"android:background="@null"android:gravity="right|center_vertical"android:hint="0" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:layout_rowWeight="1"android:gravity="center"android:background="#eeeeee"android:text="/" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:layout_rowWeight="1"android:gravity="center"android:text="1" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:layout_rowWeight="1"android:gravity="center"android:text="2" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:layout_rowWeight="1"android:text="3" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:layout_rowWeight="1"android:gravity="center"android:text="*" /><!--第3行--><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:layout_rowWeight="1"android:gravity="center"android:text="4" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:layout_rowWeight="1"android:background="#eeeeee"android:gravity="center"android:text="5" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:layout_rowWeight="1"android:background="#eeeeee"android:gravity="center"android:text="6" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:layout_rowWeight="1"android:gravity="center"android:text="-" /><!--第4行--><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:layout_rowWeight="1"android:gravity="center"android:text="7" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:layout_rowWeight="1"android:gravity="center"android:text="8" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:layout_rowWeight="1"android:gravity="center"android:text="9" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_rowSpan="3"android:layout_columnWeight="1"android:layout_gravity="fill"android:background="#eeeeee"android:gravity="center"android:layout_rowWeight="1"android:text="+" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:layout_rowWeight="1"android:text="0" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnSpan="2"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:layout_rowWeight="1"android:text="00" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnSpan="3"android:layout_columnWeight="1"android:background="#eeeeee"android:gravity="center"android:layout_rowWeight="1"android:text="=" />
</GridLayout>

核心思想:1)要铺满,所以宽高都要占满父容器

android:layout_width="match_parent"
android:layout_height="match_parent"

2) 其次,第一个编辑框,要设置右对齐,且要文字垂直居中对齐

核心代码:

android:gravity="right|center_vertical"

PS:

android:gravity="center"

这个属性的设置,目的是让TextView中的文字在TextView内部垂直水平居中显示。 

这篇关于(七)Android布局类型(网格布局GridLayout)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/820613

相关文章

Android kotlin中 Channel 和 Flow 的区别和选择使用场景分析

《Androidkotlin中Channel和Flow的区别和选择使用场景分析》Kotlin协程中,Flow是冷数据流,按需触发,适合响应式数据处理;Channel是热数据流,持续发送,支持... 目录一、基本概念界定FlowChannel二、核心特性对比数据生产触发条件生产与消费的关系背压处理机制生命周期

Android ClassLoader加载机制详解

《AndroidClassLoader加载机制详解》Android的ClassLoader负责加载.dex文件,基于双亲委派模型,支持热修复和插件化,需注意类冲突、内存泄漏和兼容性问题,本文给大家介... 目录一、ClassLoader概述1.1 类加载的基本概念1.2 android与Java Class

Android DataBinding 与 MVVM使用详解

《AndroidDataBinding与MVVM使用详解》本文介绍AndroidDataBinding库,其通过绑定UI组件与数据源实现自动更新,支持双向绑定和逻辑运算,减少模板代码,结合MV... 目录一、DataBinding 核心概念二、配置与基础使用1. 启用 DataBinding 2. 基础布局

Android ViewBinding使用流程

《AndroidViewBinding使用流程》AndroidViewBinding是Jetpack组件,替代findViewById,提供类型安全、空安全和编译时检查,代码简洁且性能优化,相比Da... 目录一、核心概念二、ViewBinding优点三、使用流程1. 启用 ViewBinding (模块级

Android学习总结之Java和kotlin区别超详细分析

《Android学习总结之Java和kotlin区别超详细分析》Java和Kotlin都是用于Android开发的编程语言,它们各自具有独特的特点和优势,:本文主要介绍Android学习总结之Ja... 目录一、空安全机制真题 1:Kotlin 如何解决 Java 的 NullPointerExceptio

CSS3 布局样式及其应用举例

《CSS3布局样式及其应用举例》CSS3的布局特性为前端开发者提供了无限可能,无论是Flexbox的一维布局还是Grid的二维布局,它们都能够帮助开发者以更清晰、简洁的方式实现复杂的网页布局,本文给... 目录深入探讨 css3 布局样式及其应用引言一、CSS布局的历史与发展1.1 早期布局的局限性1.2

Android NDK版本迭代与FFmpeg交叉编译完全指南

《AndroidNDK版本迭代与FFmpeg交叉编译完全指南》在Android开发中,使用NDK进行原生代码开发是一项常见需求,特别是当我们需要集成FFmpeg这样的多媒体处理库时,本文将深入分析A... 目录一、android NDK版本迭代分界线二、FFmpeg交叉编译关键注意事项三、完整编译脚本示例四

Android与iOS设备MAC地址生成原理及Java实现详解

《Android与iOS设备MAC地址生成原理及Java实现详解》在无线网络通信中,MAC(MediaAccessControl)地址是设备的唯一网络标识符,本文主要介绍了Android与iOS设备M... 目录引言1. MAC地址基础1.1 MAC地址的组成1.2 MAC地址的分类2. android与I

Android 实现一个隐私弹窗功能

《Android实现一个隐私弹窗功能》:本文主要介绍Android实现一个隐私弹窗功能,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 效果图如下:1. 设置同意、退出、点击用户协议、点击隐私协议的函数参数2. 《用户协议》、《隐私政策》设置成可点击的,且颜色要区分出来res/l

Android实现一键录屏功能(附源码)

《Android实现一键录屏功能(附源码)》在Android5.0及以上版本,系统提供了MediaProjectionAPI,允许应用在用户授权下录制屏幕内容并输出到视频文件,所以本文将基于此实现一个... 目录一、项目介绍二、相关技术与原理三、系统权限与用户授权四、项目架构与流程五、环境配置与依赖六、完整