alertDialog set background size - android

There is a way to set the 'black' background size of the alertDialog?
I'm not meaning the size of the alertDialog but of his background that cover all the display.
I have an alert dialog that appears in a fragment where it has some tabs, the problem of the background of the alertdialog is that cover all the display, so i cannot tap on the tabs.

AlertDialog docs and AlertDialogBuilder docs say that it is possible to change background - via AlertDialog(Context context, int theme) constructor for example, or providing Your own view for AlertDialogBuilder.
But I'm not sure if that's what You want - whole point of AlertDialog is to...be displayed for user to take action, so yes, it occludes Your fragments why wouldn't it? From Your post it looks like You are trying to move to other fragment while AlertDialog is displayed, if I understood correctly. But if just reading what's under - probably AlertDialogBuilder with custom view is way to go.

Related

How to show scroll bar always in alertdialog in android?

I have alertdialog builder which shows multiChoiceItems, there are many items so all options are not visible and scrollable list is created but scroll bar hides after some seconds. How can I make it visible all the time?
I'm not using custom builder. I know this method but how can I use it setScrollbarFadingEnabled(false)?
You can't do this to a AlertDialog builder. However it is possible to do it to AlertDialog.
Get the AlertDialog from your builder.
AlertDialog dialog = builder.create();
Then you have to show your dialog before you manipulate it.
dialog.show();
Now the methods are available and won't throw errors. Note: You can style your positive and negative buttons here too.
dialog.getListView().setScrollbarFadingEnabled(false);

Is there a way to show an Android dialog without graying out the back drop?

I want to pop open a DatePickerDialog in a certain screen, but I am required to not grey out the rest of the screen (the view behind the dialog) when the DatePickerDialog window opens. Is there a way to achieve this?
You probably would want to create your own custom dialog. You can extend DialogFramgent and change it accordingly.
See the Android doc HERE for a great example.
Or, use PopupWindow if you want a popover dialog with control of the background, see this SO post.

Android: Associate an AlertDialog with a specific view

I have tabs that when tapped will show a view for each tab. Is it possible to create an AlertDialog that is specific to a particular view and only shows when the view is shown? So if the user taps on one tab, they would see an AlertDialog but if they tap on a different tab, the AlertDialog will not show. I don't believe its possible because I believe an AlertDialog is global within the app and when shown comes to the foreground making it impossible to tap on anything else until the dialog is dismissed. But maybe I'm wrong.
No, it is not. You may try to switch to Fragments and FragmentDialog as that would allow you to 'bind' dialog to a fragment, and each fragment can sit on separate 'tab' of your app (yet, you'd need to rework your app anyway). If you want to use 'traiditional' dialog, then you have to add a logic yourself, and not show it if different than expected tab is visible.

How to apply such like design on Default Dialogs

I want to show two Dialogs (default) at the same time, no matter if second one is shown then previous lost its focus but should remain on the Screen. I tried by many ways such as:
1) Creating two Alert Dialogs
2) Creating one Alert Dialog and other one Activity as a Dialog
but i never achieved my desired task. Image is shown below that just describes how i want to show such Dialogs (default) and layout would be same as to the Default dialog but here i just describe how should the dialogs be laid out.
It's not possible to show two dialogs at the same time in the same activity.
If you do want something that looks like a second dialog, I suggest you create a layout inside the first dialog that is hidden until you make some selection.

AlertDialog or Custom Dialog

I'm developing an Android 2.2 application.
I want to show a text with an Ok button but I want to add my custom style.
What is the better choice an AlertDialog with a custom layout or a Dialog?
I'd go for AlertDialog:
It's easier to implement.
The only custom thing you have to do is an XML layout and then inflate it.
AlertDialog dialog = new AlertDialog.Builder(this)
.setView(getLayoutInflater().inflate(R.layout.custom_dialog, null))
.create();
In order to listen for UI events:
View view = getLayoutInflater().inflate(R.layout.custom_dialog, null);
Button btn = (Button)view.findViewById(R.id.the_id_of_the_button);
btn.setOnClickListener(blah blah);
AlertDialog dialog = new AlertDialog.Builder(this)
.setView(view)
.create();
You can check in android dialog docs:
The Dialog class is the base class for dialogs, but you should avoid instantiating Dialog directly. Instead, use one of the following subclasses:
AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .
when would i use an Alert Dialog?
-When i just want to inform something to the user .
-When we want use for a prompt like Do you want to go back (Yes, No, Cancel. Alert dialog comes with 3 buttons which are positive, negative and neutral which are provided by default).
-When i want to prompt user for a simple value (number/date/string...)
when would i use a Dialog?
-When i want to carry on a complex process with more buttons and widgets .
-Example:

Categories

Resources