Questions tagged [android-drawable]

In Android, a Drawable is a general abstraction for "something that can be drawn."

2993 questions
1084
votes
22 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
  • 15,041
  • 6
  • 25
  • 27
847
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?
823
votes
19 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
  • 187,060
  • 113
  • 301
  • 369
668
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
  • 37,109
  • 32
  • 120
  • 141
494
votes
11 answers

How to convert a Bitmap to Drawable in android?

How can I convert a Bitmap image to Drawable ?
Farha Ansari
  • 5,855
  • 5
  • 26
  • 22
473
votes
12 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
  • 29,432
  • 22
  • 140
  • 255
435
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,351
  • 2
  • 16
  • 3
398
votes
23 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.
  • 4,566
  • 2
  • 15
  • 26
373
votes
11 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
  • 15,716
  • 18
  • 63
  • 115
354
votes
9 answers

Programmatically set left drawable in a TextView

I have a textView in xml here.
coder_For_Life22
  • 26,645
  • 20
  • 86
  • 118
301
votes
26 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
  • 15,983
  • 17
  • 62
  • 77
219
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
  • 369,085
  • 72
  • 557
  • 602
183
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,169
  • 3
  • 16
  • 18
166
votes
13 answers

Add ripple effect to my button with button background color?

I created a button and I want to add ripple effect to that button! I created a button bg XML file: (bg_btn.xml)
rakcode
  • 2,256
  • 4
  • 19
  • 44
165
votes
13 answers

Getting Bitmap from vector drawable

In my application, I have to set a large icon for a notification. LargeIcon must be a Bitmap, and my drawables are vector images (the new feature in Android, see this link) The problem is when I try to decode a resource that is a vector image, I get…
liltof
  • 2,153
  • 2
  • 14
  • 23
1
2 3
99 100