In Android, a Drawable is a general abstraction for "something that can be drawn."
Questions tagged [android-drawable]
2841 questions
1009
votes
20 answers
How to convert a Drawable to a Bitmap?
I would like to set a certain Drawable as the device's wallpaper, but all wallpaper functions accept Bitmaps only. I cannot use WallpaperManager because I'm pre 2.1.
Also, my drawables are downloaded from the web and do not reside in R.drawable.
Rob
- 14,167
- 6
- 22
- 27
784
votes
16 answers
Android getResources().getDrawable() deprecated API 22
With new android API 22 getResources().getDrawable() is now deprecated.
Now the best approach is to use only getDrawable().
What changed?
Blodhgard
- 8,480
- 3
- 18
- 33
771
votes
18 answers
How to define a circle shape in an Android XML drawable file?
I have some problems finding the documentation of the definitions of shapes in XML for Android. I would like to define a simple circle filled with a solid color in an XML File to include it into my layout files.
Sadly the Documentation on…
Janusz
- 176,216
- 111
- 293
- 365
634
votes
1 answer
Mipmaps vs. drawable folders
I'm working with Android Studio 1.1 Preview 1. I noticed that when I create a new project I'm getting the following hierarchy:
Mipmap folders for different DPIs, no more different DPIs drawable folders.
Should I put all my resources in the mipmap…
David
- 34,355
- 30
- 113
- 139
465
votes
11 answers
How to convert a Bitmap to Drawable in android?
How can I convert a Bitmap image to Drawable ?
Farha Ansari
- 5,555
- 5
- 24
- 22
457
votes
11 answers
Mipmap drawables for icons
Since Android 4.3 (Jelly Bean) we can now make use of the res/mipmap folders to store "mipmap" images.
For example, Chrome for Android stores its icons in these folders instead of the more normal res/drawable folders.
How are these mipmap images…
Richard Le Mesurier
- 27,993
- 19
- 127
- 242
409
votes
19 answers
android:drawableLeft margin and/or padding
Is it possible to set the margin or padding for the image which we added with the android:drawableLeft?
androidNewbies
- 4,091
- 2
- 13
- 3
349
votes
10 answers
Calling setCompoundDrawables() doesn't display the Compound Drawable
After I call the setCompoundDrawables method, the compound Drawable is not shown..
Drawable myDrawable = getResources().getDrawable(R.drawable.btn);
btn.setCompoundDrawables(myDrawable, null, null, null);
Any thoughts?
hunterp
- 14,818
- 17
- 56
- 108
346
votes
22 answers
How to add an image to the "drawable" folder in Android Studio?
I need to add an image to the res/drawable folder...
When I choose new > Image Asset, it comes out a dialog to choose Asset Type...
How can I add an image to res/drawable folder?
Alan W.
- 3,921
- 2
- 13
- 22
314
votes
7 answers
Programmatically set left drawable in a TextView
I have a textView in xml here.
coder_For_Life22
- 24,973
- 20
- 82
- 117
281
votes
21 answers
How to change colors of a Drawable in Android?
I'm working on an android application, and I have a drawable that I'm loading up from a source image. On this image, I'd like to convert all of the white pixels to a different color, say blue, and then cache the resultant Drawable object so I can…
Matt McMinn
- 14,905
- 14
- 54
- 68
218
votes
5 answers
Standard Android menu icons, for example refresh
The Android SDK offers the standard menu icons via android.R.drawable.X. However, some standard icons, such as ic_menu_refresh (the refresh icon), are missing from android.R.
Is there any way to get the original icons, maybe by extracting them from…
poke
- 307,619
- 61
- 472
- 533
173
votes
17 answers
Vertical line using XML drawable
I'm trying to figure out how to define a vertical line (1dp thick) to be used as a drawable.
To make a horizontal one, it's pretty straightforward:
Kaspa
- 2,049
- 2
- 16
- 17
152
votes
5 answers
Storing R.drawable IDs in XML array
I would like to store drawable resources' ID in the form of R.drawable.* inside an array using an XML values file, and then retrieve the array in my activity.
Any ideas of how to achieve this?
gammaraptor
- 1,836
- 3
- 14
- 16