android - 如何在android中将图像添加到drawable xml

标签 android

我有一个绘制圆圈的可绘制 xml 文件。

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid

    android:color="#666666" />

<size
    android:width="120dp"
    android:height="120dp" />
</shape>

现在,我必须在可绘制文件夹中添加图像。请帮助我在哪里更改代码。

最佳答案

你可以像这样使用图层列表

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
   <item>
       <shape android:shape="oval">
           <solid
               android:color="#666666"/>

           <size
               android:width="120dp"
               android:height="120dp"/>
       </shape>
   </item>

   <item android:drawable="@drawable/your_drawable"/>
</layer-list>

关于android - 如何在android中将图像添加到drawable xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40235388/

相关文章:

Android 4.4.4 上的 java.lang.noClassDefFoundError,适用于 5.0+

java - android应用程序存储ArrayList内容的最佳方法?

android - 如何以编程方式在 android 中录制超过 3 分钟的屏幕?

android - 自定义 ListView 项目 View 中的 TextView 未填充 API 18 和 19 中的父级

android - 通过 Wifi 进行 USB 调试

android - 嵌套 Parcelling : RuntimeException - Unmarshalling unknown type code 3211319 at offset 440

android - Rxjava2、Retrofit2 - 在两个类之间传输数据。

android - 多个屏幕尺寸的 TableLayout?

java - Android 静态方法中的 Invalidate/onDraw

android - 从后台线程添加 View