Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the background drawable of an Activity's window?

Tags:

android

From an Activity, I can set the background drawable like this:

getWindow().setBackgroundDrawable(drawable)

But I can't find a method that retrieves the background drawable.

Is there one? If not, why not?

like image 315
numan salati Avatar asked Jan 30 '13 23:01

numan salati


People also ask

How do you get the background color on a view?

To get background color of a Layout: LinearLayout lay = (LinearLayout) findViewById(R. id. lay1); ColorDrawable viewColor = (ColorDrawable) lay.

How to put image in drawable XML file?

To use an image resource, add your file to the res/drawable/ directory of your project. Once in your project, you can reference the image resource from your code or your XML layout. Either way, it's referred to using a resource ID, which is the file name without the file type extension. For example, refer to my_image.

What is the preferred image format for the drawable?

A bitmap image. Android supports bitmap files in the following formats: . png (preferred), ,webp (preferred, requires API level 17 or higher), . jpg (acceptable), .


1 Answers

You can use getWindow().getDecorView().getBackground(); to retrieve the background drawable.

like image 109
JiTHiN Avatar answered Oct 04 '22 04:10

JiTHiN