android-resources

How to find out IDs or names of preloaded system drawables (bitmaps) from memory dump

烂漫一生 提交于 2019-12-03 08:09:52
I'm analyzing memory usage of our app, and has found strange Drawables , which constantly "eats" few megabytes of heap. Here are few screenshots from MAT : Dominator tree with 2 pretty big bitmaps Path to GC roots for one of above bitmaps This bitmaps always appears in heap dumps from my phone ( Samsung Galaxy Nexus, OS 4.1.1 ), no matter how long or how intensive I use our app. I've already tried to search the source of this bitmaps using MAT - with no luck. All usefull information I was able to find was width and height of bitmaps, it's both 512x512: But our app doesn't have any single

Tool to batch convert android resource bitmaps to different densities

本小妞迷上赌 提交于 2019-12-03 06:59:43
I need to post-release support different display densities on Android During development drawable-hdpi has grown to 160 png (like 20 of them 9 patch) assets I now need to convert all those bitmaps to mdpi, ldpi (layouts and drawables XML are already fine, to avoid raising OOM on LayoutInflater Is there any tool suitable to convert all those bitmaps in batch ? Sababado Here is a simple script to create lower-resolution Android drawables from higher-resolution ones. For example, given a batch of -xhdpi images, it can generate -hdpi and -mdpi images. With this script, it’s possible to export only

Storage limit in raw and asset folder in android

喜你入骨 提交于 2019-12-03 06:55:00
I want to store some video/audio files in raw folder of my application. I don't know the storage limit of raw and asset folder. Can anybody tell me how much data i can store in raw and asset folder. And also what if i store bulk data in those folder, does it will affect to speed of execution or size of application to download from market? Thanks in advance. There is no limits on any resources now after Android2.3 release the new aapt.The limitation is caused by the older aapt for system peformance reason and should not happen now. GrIsHu According to The reason for Assets and Raw Resources in

Accessing integer resources in xml

大憨熊 提交于 2019-12-03 06:36:25
问题 I have read this where found that how to access integer resources in java class but no docs for another resource. Here is Resources at res/values/integers.xml <resources> <integer name="input_field_padding" >5</integer> </resources> Tried to access the input_field_padding in EditText. <EditText android:id="@+id/user_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="@integer/input_field_padding" /> But I got the following exception java.lang

Resource arrays [duplicate]

a 夏天 提交于 2019-12-03 06:28:46
问题 This question already has answers here : Storing R.drawable IDs in XML array (6 answers) Closed 2 years ago . Is there a way to define an array in XML in which the elements are resource references? For example (it doesn't work, but it explains what I want): <integer-array name="actions_images"> <item>@drawable/pencil</item> <item>@drawable/pencil</item> <item>@drawable/pencil</item> <item>@drawable/pencil</item> <item>@drawable/pencil</item> <item>@drawable/pencil</item> </integer-array> 回答1:

ResourcesCompat.getDrawable() vs AppCompatResources.getDrawable()

此生再无相见时 提交于 2019-12-03 04:40:46
问题 I'm a bit confused with these two APIs. ResourcesCompat.getDrawable(Resources res, int id, Resources.Theme theme) Return a drawable object associated with a particular resource ID and styled for the specified theme. Various types of objects will be returned depending on the underlying resource -- for example, a solid color, PNG image, scalable image, etc. Prior to API level 21, the theme will not be applied and this method simply calls through to getDrawable(int). AppCompatResources

Android resource not found because of width and height

て烟熏妆下的殇ゞ 提交于 2019-12-03 03:18:23
I've published an Android app in the store recently that worked perfectly for almost all of my users. However, I shortly started getting a few crash reports a week with the following trace: Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xhdpi/dark_button_unpressed.png from drawable resource ID #0x7f02005d at android.content.res.Resources.loadDrawable(Resources.java:1716) at android.content.res.Resources.getDrawable(Resources.java:581) at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:162) at android.graphics.drawable.Drawable

Reference drawable from string-array in android [duplicate]

一个人想着一个人 提交于 2019-12-03 01:26:54
This question already has an answer here: Storing R.drawable IDs in XML array 6 answers how would I reference a drawable resource from the string xml file? I want to do <string-array name="my_array"> <item>@drawable/my_image</item> ... How would I do that? for arrays of drawables ids, don't use string array just use <array> then to use them, get a TypedArray if the ids TypedArray images = getResources().obtainTypedArray(R.array.my_image_ids); int resourceId = images.getResourceId(id, -1); and don't forget when you're done with the resource id and array to recycle it images.recycle(); I guess

Accessing integer resources in xml

核能气质少年 提交于 2019-12-02 20:14:19
I have read this where found that how to access integer resources in java class but no docs for another resource. Here is Resources at res/values/integers.xml <resources> <integer name="input_field_padding" >5</integer> </resources> Tried to access the input_field_padding in EditText. <EditText android:id="@+id/user_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="@integer/input_field_padding" /> But I got the following exception java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x10 Is it possible to access it in another

Audio not playing in android. android.content.res.Resources$NotFoundException: Resource ID #0x0

你离开我真会死。 提交于 2019-12-02 18:48:13
问题 I am trying to play an audio file in Android but it seems to crash and give a the ResourcesNotFoundException . The audio file is saved in the raw folder inside res. The name of the audio file is determined by a randomly generated number which is then concatenated to "audio". int res = getResources().getIdentifier ( "audio"+arrayIndex, "raw","com.din.askak" ); MediaPlayer mPlayer = MediaPlayer.create ( MainActivity.this, res ); In the logcat it seems to throw the exception on the line creating