android - Dialog with transparent background (with any color) -


i want followingi want blue translucent behind custome dialog box. not getting blue color

here code of dialog declaration:

final dialog dialog = new dialog(bookappointmentactivity.this,r.style.translucentblue );                 //dialog dialog = new dialog(bookappointmentactivity.this,  android.r.style.theme_translucent_notitlebar_fullscreen );                  dialog.setcontentview(r.layout.customedialog);                 window window = dialog.getwindow();                 window.setbackgrounddrawable(new colordrawable(android.graphics.color.transparent));                   dialog.show();  

here style.xml

<color name="transparent_green_color">@color/dialog_back</color>     <style name="translucentblue" parent="android:theme.translucent">         <item name="android:windowbackground">@color/transparent_green_color</item>     </style> 

ok got solution

first make change in theme. don't make custome theme. use android.r.style.theme_translucent_notitlebar_fullscreen

final dialog dialog = new dialog(bookappointmentactivity.this,android.r.style.theme_translucent_notitlebar_fullscreen ); 

instead of custome theme

and add following:

window.setbackgrounddrawableresource(r.color.dialog_back); 

full code:

  final dialog dialog = new dialog(context, android.r.style.theme_translucent_notitlebar_fullscreen);                       dialog.setcontentview(r.layout.customedialog);                     window window = dialog.getwindow();                      window.setbackgrounddrawable(new colordrawable(android.graphics.color.transparent));                     window.setbackgrounddrawableresource(r.color.dialog_back);                   dialog.show();               }         }); 

use color resource file color.xml , @ last not least don't forget decrease opacity of color.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -