Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to programmatically make an Activity Window transluscent?

Tags:

android

Is there a way to programmatically make an Activity Window appear transluscent? For my purposes, I cannot use static XML resources.

I attempted to set the background resource to a transluscent color, but that only make the background appear solid black.

like image 594
zer0stimulus Avatar asked Mar 21 '12 20:03

zer0stimulus


2 Answers

write it in your activity class

Window window = this.getWindow();
window.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
like image 137
Gangadhar Nimballi Avatar answered Sep 22 '22 06:09

Gangadhar Nimballi


Finally, I find a way to solve this problem.

https://github.com/ikew0ng/SwipeBackLayout/blob/e4ddae6d2b8af9b606493cba36faef8beba94be2/library/src/main/java/me/imid/swipebacklayout/lib/Utils.java

if you want to make a activity translucent

Utils.convertActivityToTranslucent(activity);

or if you want to make it opaque

Utils.convertActivityFromTranslucent(activity);
like image 27
liubaoyua Avatar answered Sep 21 '22 06:09

liubaoyua