Questions tagged [android-drawable]

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

2841 questions
78
votes
4 answers

What is the difference between Bitmap and Drawable in Android?

I googled but i couldn't find any article to describe about the difference between Bitmap and Drawable in Android.
Nikhil C George
  • 1,137
  • 1
  • 9
  • 14
73
votes
9 answers

Android Studio drawable folders

In Android Studio, I can't figure out where to put images to be used inside the app. The drawable folder isn't broken down into drawable-hdpi, drawable-ldpi, etc. I saw another question asking this and the answer was to switch to Project view…
user3397545
  • 787
  • 1
  • 5
  • 8
66
votes
9 answers

Scale image keeping its aspect ratio in background drawable

How do I make a background image fit the view but keep its aspect ratio when using as a background drawable XML? None of 's android:gravity values gives the desired effect.
tilex
  • 1,644
  • 1
  • 17
  • 32
65
votes
8 answers

How to use RoundedBitmapDrawable

Has anyone managed to use RoundedBitmapDrawable? Correct me if I'm wrong, but to my understanding, it makes a circular image from a regular rectangular image. What I've tried so far is…
gian1200
  • 3,567
  • 2
  • 27
  • 57
63
votes
11 answers

Android Studio: Drawable Folder: How to put Images for Multiple dpi?

Hi as per android documentation the drawable folder needs to have multiple sub-directories for images of different dpis. However in Android Studio creating any sub directory in the drawable folder causes it to fail to detect any images at all. On…
praveen
  • 755
  • 1
  • 8
  • 12
60
votes
7 answers

Get the ID of a drawable in ImageView

I have one ImageView and set a drawable on it. Now I need to get the ID of the drawable on click event of ImageView dynamically. How can I get it? imgtopcolor = (ImageView) findViewById(R.id.topcolor); imgtopcolor.setImageResource(R.drawable.dr); …
chikka.anddev
  • 9,196
  • 7
  • 35
  • 45
60
votes
2 answers

Understanding Android's

I don't understand how the layer-lists work. I read the official documentation with some examples but it does not work for me like expected. I want four squares which should be padded with 1dp, but nothing is like expected. Here is a screenshot…
rekire
  • 45,039
  • 29
  • 149
  • 249
56
votes
2 answers

Centering bitmap Marker (Google Maps Android API v2)

When I add a marker from a custom Bitmap, the marker is not centered at the point I specify. I'm adding it like this: // ID tramo final int tramoId = tr.getId(); // Nodos final Nodo[] nodos = tr.getNodos(); final PolylineOptions…
51
votes
8 answers

Creating & Using 9-patch images in Android

I recently heard about 9-patch images. I know its 9 tiled and is stretchable. I'd like to know more about it. How can I create a 9-patch image? Is there any tool? Can I create it from AndroidSDK or code? Main Advantages of 9-patch over regular…
Nizam
  • 5,506
  • 9
  • 40
  • 54
49
votes
4 answers

BitmapFactory.decodeResource() returns null for shape defined in xml drawable

I looked through multiple similar questions, although I haven't found a proper answer to my issue. I have a drawable, defined in shape.xml
mol
  • 2,348
  • 4
  • 18
  • 34
49
votes
6 answers

Add gradient to imageview

I want to add a gradient on the bottom of my image . Something like this : I tried something like this but I only get the gradient no image..
user1163234
  • 2,223
  • 5
  • 31
  • 56
48
votes
9 answers

How to draw a circle inside a circle using Android xml shapes?

I'm trying to make a thumb for a seekbar for my app, and I want to have an inner circle surrounded by a different, larger (semi-transparent) outer circle. I'm trying to use layer-list, but I'm having issues. Below is my code...
jas7457
  • 1,854
  • 5
  • 28
  • 45
47
votes
4 answers

How to set a shape's background in xml?

I just created a red circle using android shapes:
Waza_Be
  • 39,545
  • 47
  • 176
  • 256
47
votes
9 answers

Where are the Android icon drawables within the SDK?

In my design of UI of Android applications, I need some drawables for icons. Where are the existing drawables located within the Android SDK?
user1914692
  • 2,823
  • 5
  • 33
  • 54
45
votes
2 answers

How to change a layer-list drawable?

Trying to learn some new things and can't figure this one out, any help is appreciated. Given this simple code which is right from Google's documentation: layers.xml:
ShadowGod
  • 7,601
  • 3
  • 25
  • 31