在添加了主属性之后
发布时间:2025-06-24 17:46:53 作者:北方职教升学中心 阅读量:525
三种常见的内部元素是<foreground>、
(在制作NotePad时发现c;感觉挺实用的,
AndroidManifest自适应图标.androidid是xml的主要属性:icon。
这是实现后的示例:
启动动画示例。
以下是代码的例子:
<style name="Base.Theme.CSDN" parent="Theme.Material3.DayNight.NoActionBar"> <item name="android:windowSplashScreenBackground">@color/white</item> <item name="android:windowSplashScreenAnimatedIcon"> @drawable/splash_screen_news_avd_preview </item> <item name="android:windowSplashScreenAnimationDuration">1000</item> <item name="android:windowSplashScreenIconBackgroundColor"> @color/white </item> <item name="android:windowSplashScreenBrandingImage">@drawable/yuanshen</item> <item name="android:windowSplashScreenBehavior">icon_preferred</item> </style>
(这里的@color和@drawable只需根据自己喜欢的设置,在value-v31文件夹中运行代码,如果有windowsplashScrenbehavior,#xff0c;可以用下。在添加了主属性之后,
我们在values文件夹中找到了themes.xml文件,这是我们主要添加编辑主属性的地方。
其中,android是android的常见可选属性:roundIcon,该属性意味着启动器使用带有圆形图标的应用程序。
解决模拟器花屏问题。就写在这里)
如果在运行项目时出现花屏等类似现象,
在这个界面的左下角找到Graphics。
点击模拟器旁边的小点,点击小铅笔Edit。
windowSplashScreenAnimationDuration,设置启动画面图标动画的时间。
以下代码段是一个非常经典的例子:
<application android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.CSDN" tools:targetApi="31"> ... </application>
在mipmap文件夹中,我们可以找到ic_launcher_round.xml文件。如果你把android:删除drawable代码,然后你会发现图标变了。里面使用了<adaptive-icon>定义前景、
一般情况下,SplashScren使用windowbackground(如果windowbackground是单色的话)。
启动图片。
我在这里贴的是Kotlin代码,如果学生对Groovy有用c;请去掉左右两侧的“(””和“)”。但是,官方的建议是不要使用品牌图片。但是,在添加主要属性之前,我们需要做好准备。
一般来说,背景和单色图层资源的元素。则应在value-v33文件夹中)
让我们来介绍一下,
windowSplashScreenBackground,以特定的单色设置启动画面的背景色。很可能是因为模拟器有这个图标,意思是默认自动渲染。
windowSplashScreenBrandingImage,在启动画面底部显示图片的设置。如果还想要更长的时间它需要通过代码来实现。<background>和<monochrome>元素中去。背景和单色图层资源的元素。
这样,#xff0c;试试下面的方法。但是感觉一般很少用。
Android 12开始SplashScreen API APP启动时可以显示动画。如果需要自定义启动画面然后需要向应用主题添加属性。
windowSplashScreenBehavior,这个属性是指应用程序是否总是在Android中 图标显示在更高版本的启动画面上。
windowSplashScreenAnimatedIcon,替换起始窗口中心的图标,是显示在启动界面中间的图片或动画。
最后,感谢您的观看!
(这篇文章写得比较粗糙,还请大家多包涵)如果你想把它添加到项目中,将以下代码段添加到build中.#xff1在gradle文件中a;dependencies { implementation("androidx.core:core-splashscreen:1.0.0") ...}。这里是Automatic,改成Software就行了。windowSplashScreenAnimatedIcon,替换起始窗口中心的图标,是显示在启动界面中间的图片或动画。就可以看到相应的动画了。
自适应图标。支持矢量图像,还支持位图图像。
windowSplashScreenIconBackground,设置启动图标的背景色,当窗口背景与图标之间的对比度不够高时,原始图形与我们设置的背景重叠,只是原图标出现了。方法很简单就是嵌入它们<foreground>、最大值为1000ms。
如果在设计应用程序时,所需图标包括圆形图标,圆形背景,所以启动器必须设置android:圆形蒙版生成应用图标的roundicon属性。
由于核心SplashScren库配备了API Android带来了23和更高版本的所有设备 12 启动画面。

注意!如果不能更改,
下面是一个非常常见的例子:
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@drawable/ic_launcher_background" /> <foreground android:drawable="@drawable/ic_launcher_foreground" /> <monochrome android:drawable="@drawable/ic_launcher_foreground" /></adaptive-icon>
如果在原来的基础上做出一些改变,我们可以添加一些元素,专业点称为“将可绘对象定义为元素”。如果androidid:删除drawable代码,然后你会发现图标变了。里面使用了<adaptive-icon>定义前景、<background>和<monochrome>。
以下是一个简单的例子:
<foreground> <inset android:insetBottom="18dp" android:insetLeft="18dp" android:insetRight="18dp" android:insetTop="18dp"> <shape android:shape="oval"> <solid android:color="#0000FF" /> </shape> </inset></foreground>
实现前:

实现后:

有些学生可能会发现:我明明加了,为什么图标还是原图标?其实原因很简单在我们的原始代码中c;我们已经用图像定义了android:#xf00drawable元素c;换句话说,