4.打开_activity_main.xml_并从布局中删除TextView以删除“ Hello World!”文本。
5.现在,在_MainActivity.kt中_,添加以下行以隐藏系统导航栏(如果复制并粘贴这些行出现 Unresolved reference build errors,请单击未解决的对象,然后按Alt + Enter添加库):
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) {
hideSystemUIAndNavigation(this)
}
}
private fun hideSystemUIAndNavigation(activity: Activity) {
val decorView: View = activity.window.decorView
decorView.systemUiVisibility =
(View.SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the
// content doesn’t resize when the system bars hide and show.
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // Hide the nav bar and status bar
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN)
}
6.运行该应用程序。
现在,您基本上会看到一个空屏幕,以默认颜色作为背景:
在开始动画之前,我们只需要设置一些样式即可:红色背景及福师大校徽。
首先开始:
-
打开colors.xml
-
将_colorPrimary_和_colorPrimaryDark_更改为的红色。
-
将福师大校徽复制到drawable文件夹下。
-
打开_activity_main.xml_,然后将校徽设置为宽度和高度都为128dp的ImageView。
<ImageView
android:layout_width=“128dp”
android:layout_height=“128dp”
android:src=“@drawable/fjnu”
app:layout_constraintTop_toTopOf=“parent”
app:layout_constraintStart_toStartOf=“parent”
app:layout_constraintEnd_toEndOf=“parent”
app:layout_constraintBottom_toBottomOf=“parent”
/>
5.运行该应用程序,然后查看新更改。
====================================================================
由于MotionLayout是ConstraintLayout的一部分,并且目前仅在v2.0中有效,因此要使用它,我们首先需要更新ConstraintLayout依赖项:
-
打开_build.gradle_ (Module)
-
在依赖项部分添加此行,或将您的_constraintlayout_依赖项替换为:
implementation ‘androidx.constraintlayout:constraintlayout:2.0.0-beta4’
为了最终使动画栩栩如生,您需要执行一些简单的步骤
-
打开_activity_main.xml。_
-
将activity_main.xml的布局设置为MotionLayout。
-
在xml目录下添加一个新的_activity_motion_scene.xml_。
-
_activity_motion_scene.xml_的设置的动画内容如下:
-
将校徽缩小,缩小的校徽停留0.5到1秒并逆时针旋转360度。
-
最后,将其放大以填满整个屏幕
<MotionScene
xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:motion=“http://schemas.android.com/apk/res-auto”>
<Transition
motion:constraintSetEnd=“@+id/end”
motion:constraintSetStart=“@id/start”
motion:duration=“1000”>
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“0”
android:scaleX=“1.0” />
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“0”
android:scaleY=“1.0” />
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“20”
android:scaleX=“0.7” />
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“20”
android:scaleY=“0.7” />
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“20”
android:scaleX=“0.2” />
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“20”
android:scaleY=“0.2” />
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“40”
android:scaleX=“0.7” />
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“40”
android:scaleY=“0.7” />
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“100”
android:rotation=“-360”
android:scaleX=“10.0” />
<KeyAttribute
motion:motionTarget=“@+id/imageView”
motion:framePosition=“100”
android:rotation=“-360”
android:scaleY=“10.0” />
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
最后
我见过很多技术leader在面试的时候,遇到处于迷茫期的大龄程序员,比面试官年龄都大。这些人有一些共同特征:可能工作了7、8年,还是每天重复给业务部门写代码,工作内容的重复性比较高,没有什么技术含量的工作。问到这些人的职业规划时,他们也没有太多想法。
其实30岁到40岁是一个人职业发展的黄金阶段,一定要在业务范围内的扩张,技术广度和深度提升上有自己的计划,才有助于在职业发展上有持续的发展路径,而不至于停滞不前。
不断奔跑,你就知道学习的意义所在!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
我见过很多技术leader在面试的时候,遇到处于迷茫期的大龄程序员,比面试官年龄都大。这些人有一些共同特征:可能工作了7、8年,还是每天重复给业务部门写代码,工作内容的重复性比较高,没有什么技术含量的工作。问到这些人的职业规划时,他们也没有太多想法。
其实30岁到40岁是一个人职业发展的黄金阶段,一定要在业务范围内的扩张,技术广度和深度提升上有自己的计划,才有助于在职业发展上有持续的发展路径,而不至于停滞不前。
不断奔跑,你就知道学习的意义所在!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!