How to create a custom PopUp Menu - android

I would like to create a custom PopUp menu in Android like the one in the attached screenshot. Any pointers would be appreciated.
On click of the button "Choose Name" , you see a PopUp menu just below the button.
Thaknks.

You should take a look at building custom dialogs. In Android, a Dialog is typically in the form of a popup window. You can also do this with an Activity and apply the Dialog theme to it (mentioned in this link).

Sana,
You will probably want to look into creating a custom Dialog for your application: http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

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

How to bypass android dialog outside click

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

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.

Android Display spinners in Ok/Cancel popup dialog

I want to have a popup dialog with OK/Cancel and two spinners.
(1) Is this possible?
(2) Has this been done in any other apps?
Thanks
Yes that's possible take a look at how to implement custom dialogs:
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

Categories

Resources