简体   繁体   English

android应用程序中的资产文件夹(eclipse)

[英]Assets folder in android app (eclipse)

I had searched to create the assets folder in an android app, the solution which i had tried is <App Name>/src/assets/fonts/ 我曾在android应用程序中搜索创建assets文件夹,我尝试的解决方案是<App Name>/src/assets/fonts/

but when i try to use a ttf file in my Application, i have an error : 但是当我尝试在我的应用程序中使用ttf文件时,我有一个错误:

the code : 代码 :

mFace = Typeface.createFromAsset(mContext.getAssets(),"fonts/fontType.ttf");

and the error : 和错误:

native typeface cannot be made 无法制作原生字体

I don't know if the assets folder is in the good place. 我不知道资产文件夹是否在好地方。

The problem is at the path of asset 问题出在资产的道路上

<App Name>/src/assets/fonts/

should be 应该

<App Name>/assets/fonts/

Read more at Directory Structure of an Android Project 阅读更多Android项目的目录结构


Android project directory structure is as below Android项目目录结构如下

在此输入图像描述

In Android Studio, I tried the root "app" folder, and that didn't work. 在Android Studio中,我尝试了根“app”文件夹,但这不起作用。 I looked for the AndroidManifest.xml file and put the assets folder there. 我查找了AndroidManifest.xml文件并将assets文件夹放在那里。 That worked for me. 这对我有用。

For me it ended up being app\\src\\main\\assets 对我而言,它最终成为app \\ src \\ main \\ assets

ProjectName/assets/fonts

不在src

The assets folder is an independent folder. assets文件夹是一个独立的文件夹。

While creating an Android project itself the Assets folder is independent to the src folder. 在创建Android项目时,Assets文件夹独立于src文件夹。 Not inside the src folder. 不在src文件夹中。

Confirm that assets folder was created in the following way /assets. 确认资产文件夹是以以下方式/资产创建的。

Later create a fonts folder inside the assets folder and place fonts file inside the fonts : /assets/fonts 稍后在assets文件夹中创建一个fonts文件夹,并将fonts文件放在fonts: / assets / fonts中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM