Questions tagged [android-dialog]

Base class for Dialogs. A dialog in Android is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.

A dialog is usually a small window that appears in front of the current Activity. The underlying Activity loses focus and the dialog accepts all user interaction. Dialogs are normally used for notifications that should interrupt the user and to perform short tasks that directly relate to the application in progress (such as a progress bar or a login prompt).

Official Android Dialog Documentation

1460 questions
18
votes
5 answers

How to remove transparent dark background outside of dialog box

I want to remove a transparent dark backgrond outside of dialog box. I tried with: final Dialog dialog = new Dialog(this); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.WHITE)); …
Madhav Bhattarai
  • 847
  • 2
  • 10
  • 29
17
votes
2 answers

Using ConstraintLayout with custom Android Dialog

I'm creating a custom Dialog by extending Dialog and using setContentView(). The problem is when I try to show the Dialog it only shows the background shadow instead of my custom layout. I've managed to get the custom layout to show by wrapping it…
Aidan Laing
  • 1,260
  • 11
  • 23
17
votes
4 answers

how to programatically theme an activity to be like a dialog?

Question How does one programatically (without touching the AndroidManifext.xml) set the theme of an Activity so that it looks like a dialog? Note: I am ok with modifying the AndroidManifext.xml as long as it does not need to be modified in order to…
Eric
  • 16,397
  • 8
  • 68
  • 76
17
votes
3 answers

What is the difference between PopUpWindow and Dialog?

Basically the question is stated in the title. Any preferences in using one or another? Maybe some specific tasks where one is superior/ more efficient/ better than the other?
Denys
  • 4,287
  • 8
  • 50
  • 80
16
votes
3 answers

Set AlertDialog Positive Button Text to be Bold

Here is my code. AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View vi = inflater.inflate(R.layout.group_dialog_layout,null); …
user3098538
  • 1,201
  • 3
  • 13
  • 15
16
votes
2 answers

Show a dialog in `Thread.setDefaultUncaughtExceptionHandler`

When my android application throw an exception, I want to show a custom dialog to tell user there is something wrong happened, so I use Thread.setDefaultUncaughtExceptionHandler to set a global exception handler: public class MyApplication extends…
Freewind
  • 193,756
  • 157
  • 432
  • 708
15
votes
6 answers

How to set dialog window background to transparent, without affecting its margin

Currently, I have the following dialog, which I will perform expand/ collapse animation on its items. This dialog is created via the following code import android.support.v7.app.AlertDialog; final AlertDialog.Builder builder = new…
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
15
votes
4 answers

How to get dialog size?

I am looking for a way to get size of a custom dialog. I went through this question, but the only answer given is pretty useless, because if I try mDialog.getWindow().getAttributes().height; it only returns -2, which is a constant for WRAP_CONTENT…
slezadav
  • 6,104
  • 7
  • 40
  • 61
14
votes
4 answers

How to prevent BottomSheetDialogFragment from dismissing after a navigation to another fragment?

I am using NavigationComponent on my App. I have an specific flow where after a click on a button of BottomSheetDialogFragment the app should navigate to another fragment. But when that Fragment is popped I need to navigate back to the previous…
14
votes
4 answers

onContextItemSelected is not triggered when it is called from Dialog window

Dialog dialog; private void opendialog() { dialog = new Dialog(MainActivity.this); dialog.setContentView(R.layout.popup); dialog.setTitle(R.string.msettings); RelativeLayout reply_layout = (RelativeLayout) dialog …
Sai
  • 15,188
  • 20
  • 81
  • 121
14
votes
4 answers

Change Android Dialog button text size via styles

I am trying to enlarge the text size on all of my applications dialog buttons via styles. The following code will change the buttons background colour and even the text case but for some reason the textSize item is not honoured:
14
votes
4 answers

findViewById() returns null for Views in a Dialog

The problem is, no matter where or how I call for this layout's components, they always return null. setView(inflater.inflate(R.layout.search_layout, null)) This works fine. It displays the layout inside the Dialog, yet, the children are always…
14
votes
1 answer

Get positive Button in DialogPreference

Is there a way to get the positive button of a DialogPreference in any of its events? I would like to disable it initially, and make it enabled once a EditText validates.
Bridget the Midget
  • 842
  • 10
  • 21
13
votes
3 answers

Android Alert Dialog Background Issue API 11+

I create a AlertDialog with the code below. For some reason I'm getting an extra background (see pic) on Honeycomb and above. The code crashes fine for anything below honeycomb. MyCustomDialog is simply Theme.Dialog for < API-11 and…
Ali
  • 12,354
  • 9
  • 54
  • 83
13
votes
1 answer

How to draw behind the system status bar in a Jetpack Compose Dialog

I disabled fitSystemWindows via WindowCompat.setDecorFitsSystemWindows(window, false) to draw behind the status bar and I am using the insets accompanist library to get the respective insets for adding padding to specific composables. However, if I…