Android dialogue transparent

I want to get rid of the border in my dialog box and make it completely transparent, as if the image were at the top of the screen.

enter image description here

My xml dialog is

<?xml version="1.0" encoding="utf-8"?> 

 <ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:visibility="invisible"/> 

+29
android
May 19 '11 at 13:04
source share
6 answers

Try entering the code

 Dialog mDialog = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); 
+94
May 19 '11 at 13:08
source share

try the following:

 mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0)); 
+59
Aug 18 2018-11-18T00:
source share

To get a translucent effect, such as 50% opacity, use:

 Drawable d = new ColorDrawable(Color.BLACK); d.setAlpha(130); mDialog.getWindow().setBackgroundDrawable(d); 

'130' can be changed (0-255) to obtain the desired opacity.

+17
Jan 19 '13 at 18:29
source share

try the following: -

 final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(R.layout.splash); dialog.show(); 
+10
04 Oct '13 at 7:17
source share

For API 11+

 Dialog mDialog = new Dialog(mContext, android.R.style.Theme_Holo_Light_Panel); 
+1
May 31 '14 at 11:21
source share

The easiest way to do this is that in your DialogFragment onCreate () method, call

 setStyle(DialogFragment.STYLE_NO_FRAME, 0); 

And if the view that you returned to onCreateView has no background, the background of the dialog will be just transparent.

Why? DialogFragment.STYLE_NO_FRAME means that the OS will not do any drawing in the dialog box, and your view is 100% responsible for drawing everything about the dialog.

0
Dec 29 '15 at 19:08
source share



All Articles