Transparent AlertDialog has black background
The problem is that AlertDialog builder
is actually not good for designing transparent dialog and will and always have this black background which is actually a Theme for it, instead use the Dialog
to create a transparent theme instead.
sample:
Dialog alertDialog = new Dialog(this);
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
alertDialog.setContentView(R.layout.tabs);
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
alertDialog.show();
Using Dialog
does not require any theme manipulation for transparent background so it is basically easy.
Remove Black background from Alert Dialog Box - Android
Hope this will help you a lot
I think its default theme color which is Black so you have to check the import of your AlertDialog
it should be import android.support.v7.app.AlertDialog;
and one more thing you should use custom color for Background like below
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Remove black background on custom dialog
public MyAlertDialog(
Context context,
int theme
) extends AlertDialog {
super(context, theme);
getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
}
Remove grey background for flutter alert dialog
Just launch the dialog with de navigator instead of using the showDialog() and use a PageRouteBuilder
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (context, _, __) => AlertDialog(),
opaque: false),
);
Dialog with transparent background in Android
Add this code
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
Or this one instead:
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
Make alert dialog background transparent
If you haven't read Style attributes of custom styled AlertDialog question, you should go ahead and read. The answer suggests to use Dialog
instead of Alert Dialog
. Moreover reading Why does LayoutInflater ignore the layout_width and layout_height layout parameters I've specified? issue with LayoutInflater
might clear a bit more. Hope it helps. Try it and let me know if it works.
Related Topics
Flutter Does Not Find Android Sdk
Searchview's Oncloselistener Doesn't Work
List of Files in Assets Folder and Its Subfolders
Android App Bundle with In-App Locale Change
Horizontal Scrolling Grid View
How to Send JSON Object to Server Using Volley in Android
Search in Listview with Edittext
Android 5.0 Material Design Style Navigation Drawer for Kitkat
How to Auto-Start an Android Application
Drag and Drop Items in Recyclerview with Gridlayoutmanager
Android: How Do Bluetooth Uuids Work
Http Request in Android with Kotlin
Android Studio Stuck on "Gradle: Resolve Dependencies '_Debugcompile'" or 'Detachedconfiguration1'
How to Run Media Scanner in Android
Drawing Multiple Lines in Edittext E.G. Notepad
Upload an Image and Audio in One Request in Android
How to Implement Draggable Map Like Uber Android, Update with Change Location