How to bypass android dialog outside click - android

What I want to do is to show the dialog message but make it still possible to click on the items behind. On any click, the dialog would dismiss
Right now I need to click once to dismiss the dialog and a second time to click on a field.
It is something possible ? Or is there an alternative to using Dialogs?
Edit: Solution found by adding Layout Flags to the window.
In kotlin:
dialog.window?.setLayout(ConstraintLayout.LayoutParams.FLAG_NOT_FOCUSABLE, ConstraintLayout.LayoutParams.FLAG_NOT_FOCUSABLE)

By using Dialog you cannot achieve what you are looking for. instead of using Dialog USE FRAGMENT.
The examples are given in official documentation here.

You Can define a full layout in the background of the dialog and set onClick listener to that layout

Related

Custom popup box android studio

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

Create an options menu from scratch

I wanted to create an options menu as seen in this image: http://i.imgur.com/Mf0PSy8.png
But the problem is, the only way that I found to create this type of menu is by calling onCreateContextMenu method and I don't want it to only appear when user long-press an item.
I want it, for example, to show up when user click a specific button linked to a function.
How can I do it?
You can explicitly show the option/context menu programmatically by calling Activity.openOptionsMenu() / Activity.openContextMenu(View view).
You're looking for a Dialog Fragment. These work just like a Fragment class but can be displayed as a dialog. You can find more on using a Dialog Fragment in this tutorial to do whatever you would like

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.

How to set the custom dialog on exact location when i click on view in android?

When I click on image then custom dialog is show on Top of the screen so Please can any one suggest me that how to set custom dialog at the exact location that was clicked
You can check-out this link if you want to stick to custom dialog, but if you are interested then you can use pop up window instead of custom dialog, its very easy to use popup window and you can position it nice and easy.
For this purpose u can use PopupWindow to fit the view at location u want. u can setcontentview here as well similar to custom dialog.

display a view when an activity starts

I need to display a certain view when an activity starts, and when the user click ckecked to dismiss the view. It look like this
:
Has anyone an idea how can I do this? Any idea is welcome.
Yes, you can use a custom dialog
just create a custom XML and inflate it into your dialog object
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.show();
and then dismiss it by calling dialog.dismiss();
create custom dialog using below link and open it when activity starts...
you need to increase the margin to proivde more spaces
Have a look at custom dialog examples -
custom dialog 1
custom dialog 2
yes, you can use PopupWindow for Creating window
see these tutorila for adding PopupWindow in your Activity:
Using the PopupWindow class in Android apps
Example of using PopupWindow
You could use a RelativeLayout for this. When the user clicks check, the visibility of the 'upper' layout must be set to GONE.

Categories

Resources