从XML访问android资产

从XML访问android资产,android,image,assets,Android,Image,Assets,我的Android应用程序中有很多图像,我试图将它们组织到assets目录下的文件夹中,而不是将它们全部放在drawable目录中 我的问题是如何通过XML访问资产目录。例如: <ImageView android:id="@+id/image_team_logo" android:src="/assets/teamlogos/ARI" android:layout_height="25dp" a

我的Android应用程序中有很多图像,我试图将它们组织到assets目录下的文件夹中,而不是将它们全部放在drawable目录中

我的问题是如何通过XML访问资产目录。例如:

        <ImageView android:id="@+id/image_team_logo" 
            android:src="/assets/teamlogos/ARI" 
            android:layout_height="25dp" 
            android:layout_marginLeft="5dp" 
            android:layout_marginTop="10dp" 
            android:layout_width="296dp" android:scaleType="matrix"/>


不起作用。我可以在src字符串中输入一些东西来实现这一点吗?或者只能使用代码中的AssetManager访问资产。

为什么不将图像放在“可绘制”文件夹中?那是他们的归宿。然后可以使用如下内容以XML形式访问这些图片:

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/your_file"
 />


使用访问位于“资产”文件夹中的文件,这将返回所需文件的InputStream。我不知道通过XML访问它们的任何方法。

我认为您不能使用资产目录来访问它们。。。资产是用来装罐子之类的东西的。drawables中缺少目录是令人讨厌的,但可以通过名称最小化。例如:activityxpto\u bed\u ImageDrawable文件夹不允许使用子文件夹,我试图以一种方式管理我的资产,这样就不会是一场狗屎秀……但听起来Android希望你只有100张图片都在同一个目录中……是的,在更大的项目中,这太糟糕了。你可以想一个系统来命名你的图片在可绘制文件夹。。。还要注意,有四种类型的可绘制文件夹: