For totally transparent dialog you can use this :
Step 1> Create a colors.xml file in the ‘values’ folder under ‘res’ and add the following line..
<drawable name="transparent">#00000000</drawable>
Step 2> Create a styles.xml file in the ‘values’ folder under ‘res’ and the following lines…
<style name="Transparent"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle"> @android:style/Animation.Translucent </item> <item name="android:windowBackground">@drawable/transparent</item> <item name="android:windowNoTitle">true</item> <item name="android:colorForeground">#fff</item> </style>
(I guess the tags and attributes are self explanatory…)
Step 3> Actually, that's it……………………
Let’s add this to a dialog…..
Step 4> Create a class with the following lines……
public class DialogBox extends Dialog { public DialogBox(Context context, int theme) { super(context, theme); setContentView(R.layout.dialog); okButton = (Button) findViewById(R.id.dialog_OkButton); setListeners(); } }
(Make sure you create a layout for the dialog)
Step 5> Next create an activity class as follows….
public class T_Temp extends Activity { private DialogBox dialog; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); dialog = new DialogBox(this, R.style.Transparent); dialog.show(); } }
or you can use this to make dialog attractive to add blur effect ....
Just check this out: there is near about 30% transparency...
dialog = new AlertDialog.Builder(WordCube.this) .setTitle(WordCube.this.getResources().getString(R.string.app_name)) .setMessage(s) .setIcon(R.drawable.logo) .setPositiveButton(R.string.btn_close, null) .show();
Below shows the code needed to add blur and remove dimming of the background (as I think the blur looks nicer when the background is well lit).
view plaincopy to clipboardprint? WindowManager.LayoutParams lp = dialog.getWindow().getAttributes(); lp.dimAmount=0.0f; dialog.getWindow().setAttributes(lp); dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);