简体   繁体   中英

Drawables in Assets

There are several drawable folders in android. the mdpi , hdpi , xhdpi etc. So when I have a .png file for mdpi , hdpi etc. with the same filename but different resolutions, android will automatically pick the one that is best for my device, right?

I need to do the same with assets. I have a LoaderScreen class in my game which loads all the resources in the beginning I need into a skeleton class, so I can access them easily later in the game. However, I don't know how to place 2 pictures with the same filename but different resolutions in the assets so I can load them like that :

//returns the picture, myasset.png is the filename in the assets
loader.load( "myasset.png" )

Is there any way to do this?

You do not need to put them in assets, place them in the appropriate drawable folders.

If you need to access them programmatically you can get the drawable this way.

 context.getResources().getDrawable(R.drawable.myasset);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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