Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get background drawable of view

The getBackgound() returns BitmapDrawable

Log.d(null,"drawable: " + v.getBackground());

How to get the drawable as R.drawable.xxx?

like image 471
user1623176 Avatar asked Jan 11 '13 17:01

user1623176


1 Answers

view.getBackgroundDrawable();

Use this to get the background drawable . This will return drawable

Edit

this working in versions below jelly bean , when this answer was written now this method is deprecated in latest versions

New Edit

For versions after jellybean try

 view.getBackground()

If someone wants to compare the drawables follow this answer

like image 129
edwin Avatar answered Oct 09 '22 06:10

edwin