安卓10桌面开发,圆角图标
时间: 2023-11-28 19:04:40 浏览: 32
安卓10中的圆角图标可以通过以下步骤实现:
1. 在Android Studio中创建一个新项目,并在drawable文件夹中添加一个圆角矩形的XML文件,例如rounded_corner.xml:
```
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white" />
<corners android:radius="16dp" />
</shape>
```
2. 将原始图标(png格式)放入mipmap文件夹中。
3. 在drawable文件夹中创建一个新的XML文件,例如ic_launcher_background.xml,内容如下:
```
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/rounded_corner" />
<item android:drawable="@mipmap/ic_launcher_foreground"
android:gravity="center" />
</layer-list>
```
注意:这里的`ic_launcher_foreground`是你的应用程序图标,可以在`AndroidManifest.xml`中找到。
4. 在AndroidManifest.xml文件中为应用程序和活动设置新的圆角图标和圆角启动器背景。例如:
```
<application
android:icon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/ic_launcher_round"
... >
<activity
android:name=".MainActivity"
android:icon="@mipmap/ic_launcher_round"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme">
...
</activity>
...
</application>
```
这样就可以在安卓10的桌面上显示圆角图标了。