Android Popup menu showing scrolling - android

I am show popup menu on image view click, some time it is showing all menu items and some time it is showing items with scroll view. What should I supposed to do. Because I have been not get any clue from documentation and I have also googled it. I know, some where I am missing some thing, but don't know. Below are images
I want second one.
Here is my xml code
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<item
android:id="#+id/action_card_item_copy"
app:showAsAction="always"
android:orderInCategory="100"
android:title="#string/action_card_item_copy" />
<item
android:id="#+id/action_card_item_rename"
app:showAsAction="always"
android:orderInCategory="101"
android:title="#string/action_card_item_rename" />
<item
android:id="#+id/action_card_item_delete"
app:showAsAction="always"
android:orderInCategory="102"
android:title="#string/action_card_item_delete" />
<item
android:id="#+id/action_card_item_export"
app:showAsAction="always"
android:orderInCategory="103"
android:title="#string/action_card_item_export" />
<item
android:id="#+id/action_card_item_commnent"
app:showAsAction="always"
android:orderInCategory="104"
android:title="#string/action_card_item_comment" />
</menu>

I think, it is due to the screen congestion. Always popup menu shows top of the view or down of the view. If popup menu is don't have enough space, the scroll bar will come in the popup menu.

PopupMenu displays a Menu in a modal popup window anchored to a View.
The popup will appear below the anchor view if there is room, or above
it if there is not.
In your case, since there is not enough room to show the popup above the anchor(menu icon) & the space below the anchor is limited, it automatically switches to a Scroll view.
Some dirty technique by violating the guidelines is to set the anchor
view of PopUpmenu to "do something" Imageview. Since ImageView is
above the menu icon, it will have more space below as the anchor & will show the entire popup.

Related

Popup Dialog as Menu when Menu is clicked

I want to implement Dialog where I will be able to set values.
I also would want to Dialog will Popup when I click on three dots (Menu) on Toolbar.
So far I've got menu
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<item
android:id="#+id/menu_allclients_min_date"
android:orderInCategory="200"
android:title="#string/menu_min_date"
app:showAsAction="never" />
<item
android:id="#+id/menu_allclients_max_date"
android:orderInCategory="201"
android:title="#string/menu_max_date"
app:showAsAction="never" />
<item
android:id="#+id/menu_allclients_min_amount"
android:orderInCategory="202"
android:title="#string/menu_min_amount"
app:showAsAction="never" />
<item
android:id="#+id/menu_allclients_max_amount"
android:orderInCategory="203"
android:title="#string/menu_max_amount"
app:showAsAction="never" />
Now, when Menu is clicked it show as list of four items. But It isn't a way I want to implement it.
I would also know is there any listener when Menu icon( three dots ) is clicked. It would solve my problem.
For help i sugest, if you dont have more than 2 menu itens, make a menu item set the 3 dots as icon and always as showasaction. After that in on menu item selected in your activity make a switch to check item selected and if is the 3 dots item make the dialog.

android fragment activity menu

I have a class that extends FragmentActivity. No I want to show my menu items at the top of the screen like in actionbar. How can I do this ?
I have created the menu items and they are visible hen the hardware button for menu is pressesd but I want to sho them at the top of the screen.
Basically, this happens in devices with physical menu button. In devices without that button, all options are displayed in the action bar.
You can force a menu item to be displayed in the action bar by addind "showAlways" to the item that you want.
showAsAction=“always”
An small example
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="always" />
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="always" />
</menu>
You must need to ensure that you have enough space for the menu items.
To ensure that I'll have enough space, I use to create a menu with only one item. Then, inside this item, I create another menu. This way, only one button is displayed and all items appear in a floating pop up menu. The main idea is below:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/overflow_item"
android:icon="#drawable/ic_overflow_icon"
android:title="#string/options"
android:showAsAction="always" />
<menu>
<item android:id="#+id/action_clear"
android:title="#string/clear"
android:showAsAction="always" />
</menu>
</menu>

How to show a message when focus on a view in android app

my code is......
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.user.designingapp.CapCustomize">
<item
android:id="#+id/navigate"
android:orderInCategory="300"
android:title="User"
android:icon="#drawable/back"
app:showAsAction="ifRoom"/>
<item
android:id="#+id/share"
android:orderInCategory="300"
android:title="Use"
android:icon="#drawable/share"
app:showAsAction="ifRoom"/>
I want that when i bring the cursor on these two item's image .there should show a message as name of items just like in the above image...
You can use a PopupWindow in android to achieve this. Here is an example.
If you want it to look like the menu items or want to use the menu xml, you can use PopupMenu which also have a v7 compatibility version. Example.
Also, if this is a button or image and you only want to show popup text as help or as a hint, there is a contentDescription attribute in which you can specify the text, which will show on long press.

Android ActionBar overflow menu style

I've set up a simple menu with one position like this:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="#+id/action_language" android:title="#string/language"
android:orderInCategory="100" />
</menu>
using
Theme.AppCompat.Light.DarkActionBar
style. When I click the three dots the menu position appears instead of the icon, not below it? Is there any way to make it appear under the icon, not 'on' it?
Actually you can't do anything with this icon, but you can create menu item with android:actionLayout="#layout/custom_lauout". Then you can create Popup Window, which allows such positioning. In popupWindow you will show all items that must show under "three dots item".
Here rea a few links which can help you: http://developer.android.com/reference/android/widget/PopupWindow.html
https://stackoverflow.com/a/23516493/3864698

how to start placement of action buttons from the left in action bar

I am new to android development. Hence, I'm still in the getting-the-hang-of-it mode. I have started off my app by creating an xml file in the res/menu folder, the code for which is shown below. I need help with is placing the first (add) button in the left hand corner, where the title bar is supposed to be located, followed by the remove button in the centre, and finally the overflow menu in the last third. These three entities should be evenly spaced out. Additionally, I have managed to get rid of the app name and icon from the left hand corner.
Any help will be much appreciated.
Thanks in advance
<?xml version="1.0" encoding="utf-8"?>
<item android:id="#+id/setting"
android:title="#string/action_settings"
android:orderInCategory="100"
android:showAsAction="never" />
<item android:id="#+id/add_contact"
android:title="#string/action_add"
android:orderInCategory="1"
android:showAsAction="ifRoom" />
<item android:id="#+id/remove_contact"
android:title="#string/action_remove"
android:orderInCategory="2"
android:showAsAction="ifRoom" />
This is what I want it to look like. It is a screen shot of the Nexus 4 contacts manager. However, I want buttons not tabs:
http://i.imgur.com/iDwUCJl.png
Current output: http://i.imgur.com/sQU3Jjq.png

Categories

Resources