When I switch from Activity to AppCompatActivity in Android development, the dialog box seems to have a UI issue.
Here's how the dialog buttons look like using Activity:
Here's how the dialog buttons look like using AppCompatActivity:
Crop Photo is the Positive button, Full Photo is the neutral button, and the cancel buttons looks out of place. Can this be fixed or do I overlook anything?
I have also tried using import android.support.v7.app.AlertDialog or the default android AlertDialog, both result is the same.
This is how material design works. The affirmative action (the positive button) is always placed on the right, then on the left of it is the dismissive action.
Technically the guideline says that "Dialogs should not include more than two actions.", but it is fine if it doesn't leave the dialog in an indeterminate state. However, you may want to create your own dialog layout with a list instead of relying simply on the action buttons if you think the look-and-feel is bad.
Related
When the user opens the app for the first time, I want my app to have a custom popup box or a popup model next to a button so which tells what a button does
Here's an example -
I can use sharedpreferences to make it visible only for the first time.
But, how do I make it?
you can use Dialog and customize the position and appearance of it i leave some links below to know how to do it:
diologs on android:
https://developer.android.com/guide/topics/ui/dialogs
changing position of dialog:https://www.tutorialspoint.com/how-to-change-the-position-of-the-dialog-on-screen-android
creating custom dialog using Material design:
https://material.io/components/dialogs/
for customizing dialog there is outer ways to but material design is simpler
I've got a Floating Action Button and when I click on it I open a DialogFragment.
When the dialog is opened, the button is below the dialog. My question is, how do I position the button after the onclick event on top of the DialogFragment?
Well, I would do this trick : use Fragment and adjust it to look like dialog( you even can use dialog fragment theme ). Then use the same FAB on fragment layout ( Even better you can make transition view for fab. something like zoom out/in )... Here is the complete example uploaded on Github for you :-)
https://github.com/mabuthraa/Android-FabOverDialog
I will try later to improve that example by using Fragment theme and transition.
Good luck,'.
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.
I am using a dialog themed activity in android to show a popup from a application context. The dialog has a transparent theme, but the issue is that I want the underlying activity to have focus and not the popup though the popup must be visble. How do I achieve this in android?
I think you would have to use a Fragment and just make it look like a popup dialog.
You can not switch focus between activities. There's only one activity "on focus" at the time, and is the one that is being displayed at that point. The transparent background doesn't mean you can access the activity below.
If i don't get it wrong, you want to be able to interact with the activity's controls while having a "Dialog" on the screen. Any sort of Dialog class from Android will not help, since they take the focus away. Not really sure about PopupWindow, but i'm guessing will be the same thing as the documentation says "that appears on top of the current activity."
You are going to have to create a custom dialog using a RelativeLayout/FrameLayout within your activity.
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.