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?
To get background color of a Layout: LinearLayout lay = (LinearLayout) findViewById(R. id. lay1); ColorDrawable viewColor = (ColorDrawable) lay.
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.
A bitmap image. Android supports bitmap files in the following formats: . png (preferred), ,webp (preferred, requires API level 17 or higher), . jpg (acceptable), .
You can use getWindow().getDecorView().getBackground();
to retrieve the background drawable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With