2024年安卓最新Android开发-软件版本升级与黑暗模式的适配【Android 10】,移动端h5页面开发工具

最后

分享一份工作1到5年以上的Android程序员架构进阶学习路线体系,希望能对那些还在从事Android开发却还不知道如何去提升自己的,还处于迷茫的朋友!

  • 阿里P7级Android架构师技术脑图;查漏补缺,体系化深入学习提升

  • **全套体系化高级架构视频;**七大主流技术模块,视频+源码+笔记

有任何问题,欢迎广大网友一起来交流

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!


为了解决黑暗模式的问题,我们首先需要知道安卓10如何分辨是否为黑暗模式,这里Google官方为我们提供了API。

Google官方文档的介绍:

https://developer.android.google.cn/guide/topics/ui/look-and-feel/darktheme

实现

首先在style.mxl主题继承DayNight主题,我们的就有了适配黑夜主题的能力

在这里插入图片描述

既然有了夜间模式主题,那接下来就要针对夜间模式做出适配,表现在字体和背景等方面,这些都和value.xml中的值有关,为了适配黑夜模式,我们要将values文件夹复制一份另存为values-night,成功之后AS的values文件夹下会有普通和night两个选项,我们就可以对这两个文件夹里的xml进行编辑进行不同模式的适配看了。

在这里插入图片描述 在这里插入图片描述

在我们需要适配的xml中,需要分别在values和values-night设定不同的值,而且名字要一样,否则会报错,这里改变了之前看起来不自然的主菜单为例,现在不能将android:xxxColor直接硬编码为"#XXXXX"(颜色代码)了,需要正确改为"@color/xxxxx",因为硬编码是不会被适配的,例如:

lv_index_unit.xml
<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout 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=“100dp”

android:background=“@color/colorUnitBackground”>

<TextView

android:id=“@+id/tv_tag”

android:layout_width=“80dp”

android:layout_height=“15dp”

android:layout_marginBottom=“10dp”

android:gravity=“center”

android:text=“@string/tv_tag”

android:textSize=“12sp”

android:textStyle=“italic”

app:layout_constraintBottom_toBottomOf=“parent”

app:layout_constraintEnd_toStartOf=“@+id/tv_text”

app:layout_constraintStart_toStartOf=“parent” />

<TextView

android:id=“@+id/tv_title”

android:layout_width=“230dp”

android:layout_height=“30dp”

android:layout_marginTop=“10dp”

android:gravity=“start”

android:orientation=“horizontal”

android:text=“@string/tv_title”

android:textColor=“@color/colorUnitTitle”

android:textSize=“22sp”

android:textStyle=“bold”

app:layout_constraintStart_toStartOf=“@+id/tv_text”

app:layout_constraintTop_toTopOf=“parent” />

<TextView

android:id=“@+id/tv_text”

android:layout_width=“190dp”

android:layout_height=“40dp”

android:layout_marginStart=“10dp”

android:layout_marginTop=“5dp”

android:gravity=“start”

android:text=“@string/tv_text”

android:textColor=“@color/colorUnitText”

android:textSize=“12sp”

app:layout_constraintStart_toEndOf=“@+id/iv_icon”

app:layout_constraintTop_toBottomOf=“@+id/tv_title” />

<TextView

android:id=“@+id/tv_time”

android:layout_width=“100dp”

android:layout_height=“15dp”

android:layout_marginEnd=“10dp”

android:layout_marginBottom=“20dp”

android:gravity=“end|center_vertical”

android:text=“@string/tv_time”

android:textSize=“12sp”

android:textStyle=“italic”

app:layout_constraintBottom_toBottomOf=“parent”

app:layout_constraintEnd_toEndOf=“parent” />

<ImageView

android:id=“@+id/iv_remove”

android:layout_width=“35dp”

android:layout_height=“35dp”

android:layout_marginEnd=“30dp”

android:layout_marginBottom=“10dp”

android:contentDescription=“@string/iv_remove”

app:layout_constraintBottom_toTopOf=“@+id/tv_time”

app:layout_constraintEnd_toEndOf=“parent”

app:srcCompat=“@drawable/icon_delete” />

<ImageView

android:id=“@+id/iv_icon”

android:layout_width=“60dp”

android:layout_height=“60dp”

android:layout_marginStart=“15dp”

android:layout_marginTop=“10dp”

android:contentDescription=“@string/iv_remove”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toTopOf=“parent”

app:srcCompat=“@drawable/icon_notepad” />

<TextView

android:id=“@+id/tv_id”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:textColor=“#00FF0000”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toTopOf=“parent” />

</androidx.constraintlayout.widget.ConstraintLayout>

activity_notepad.xml
<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout 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:fitsSystemWindows=“true”

tools:context=“.ActivityNotepad”>

<ScrollView

android:id=“@+id/sv”

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:background=“#FFFFFF”

app:layout_constraintBottom_toBottomOf=“parent”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintHorizontal_bias=“0.0”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toTopOf=“parent”

app:layout_constraintVertical_bias=“0.0”>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:background=“@color/colorNotepadBackground”

android:orientation=“vertical”>

<EditText

android:id=“@+id/tv_title”

android:layout_width=“match_parent”

android:layout_height=“60dp”

android:layout_margin=“10dp”

android:autofillHints=“”

android:ems=“10”

android:fontFamily=“sans-serif-black”

android:gravity=“start”

android:hint=“@string/et_title_hint”

android:inputType=“textPersonName”

android:textColor=“@color/colorNotepadTitle”

android:textSize=“30sp” />

<com.example.notepad.MultilineTextEditWithUnderLine

android:id=“@+id/et_text”

android:layout_width=“match_parent”

架构师筑基包括哪些内容

我花了将近半个月时间将:深入 Java 泛型.、注解深入浅出、并发编程.、数据传输与序列化、Java 虚拟机原理、反射与类加载、高效 IO、Kotlin项目实战等等Android架构师筑基必备技能整合成了一套系统知识笔记PDF,相信看完这份文档,你将会对这些Android架构师筑基必备技能有着更深入、更系统的理解。

由于文档内容过多,为了避免影响到大家的阅读体验,在此只以截图展示部分内容

注:资料与上面思维导图一起看会更容易学习哦!每个点每个细节分支,都有对应的目录内容与知识点!



这份资料就包含了所有Android初级架构师所需的所有知识!

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

目录内容与知识点!**

[外链图片转存中…(img-BkBi9gdw-1715013989363)]
[外链图片转存中…(img-RJ6qSBhb-1715013989364)]
这份资料就包含了所有Android初级架构师所需的所有知识!

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 26
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值