Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 从xml文件获取可提取的资源_Android - Fatal编程技术网

Android 从xml文件获取可提取的资源

Android 从xml文件获取可提取的资源,android,Android,我在assets文件夹中有一个背景xmldesc文件,如何获取可绘制的对象? xml文件如下所示: <?xml version="1.0" encoding="utf-8"?> 只需将文件放在drawable文件夹中,您就可以从那里以R.drawwable.filename(通过代码)和@drawable/yourfilename(通过XML)的形式获取它 通常,不应将shape.xml文件放在资产文件夹中。在“资源”文件夹中,我们通常会放置自定义字体、音频文件、视频文件

我在assets文件夹中有一个背景xmldesc文件,如何获取可绘制的对象? xml文件如下所示:

<?xml version="1.0" encoding="utf-8"?>



只需将文件放在drawable文件夹中,您就可以从那里以R.drawwable.filename(通过代码)和@drawable/yourfilename(通过XML)的形式获取它


通常,不应将shape.xml文件放在资产文件夹中。在“资源”文件夹中,我们通常会放置自定义字体、音频文件、视频文件等。

在布局中,您可以将可绘制文件设置为背景,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/drawable_name_without_the_.xml"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>

无法使用,因为他的文件是资产文件夹,而不是可绘制文件夹。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/drawable_name_without_the_.xml"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>