代码A由Android自动生成。
我希望用颜色值代替<background android:drawable="@color/ic_meter_launcher_background"/>,但是代码B和代码C都错了。
我该怎么做?
码A
ic_meter_launcher_background.xml文件
ic_launcher.xml文件
码B
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/#3DDC84"/>
<foreground android:drawable="@drawable/ic_meter_launcher_foreground"/>
</adaptive-icon>代码C
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#3DDC84"/>
<foreground android:drawable="@drawable/ic_meter_launcher_foreground"/>
</adaptive-icon>发布于 2022-09-08 10:01:48
您可以覆盖Android应用程序的任何资源,甚至框架本身:
<color tools:override="true" name="ic_meter_launcher_background">#3DDC84</color>
在您的资源XML文件头中,tools应该是xmlns:tools="http://schemas.android.com/tools"。
发布于 2022-09-12 10:07:08
你可以这样做:
ic_launcher.xml文件
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_meter_launcher_background"/>
<foreground android:drawable="@drawable/ic_meter_launcher_foreground"/>
</adaptive-icon>ic_meter_launcher_background.xml
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3F3F4A"
android:pathData="M0,0h108v108h-108z" />
</vector>https://stackoverflow.com/questions/73599079
复制相似问题