Android Menu item Customization - android

I have an Xamarin android menu ui code as follows
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group
android:checkableBehavior="single">
<item
android:id="#+id/sync_now"
android:checked="false"
android:icon="#drawable/ic_logo"
android:title="Sync Now"/>
</group>
</menu>
I am trying to get a split view on this hazard icon along with the transactions count displayed on the right side of the menu group items shown in the image below but am having no luck.
can someone please tell me how i can do this?

I achieved the above ui by creating a different layout file for everything after sync and added it to the item tag as:
<item
android:id="#+id/sync_now"
android:checked="false"
android:icon="#drawable/ic_syncNow"
android:title="Sync Now"
app:actionLayout="#layout/syncNowCounter"/>
make sure you use app:actionLayout instead of android:actionLayout or it will not work.

Related

Customize Android Menu Navigation Drawer

i am using the Support Library Navigation Drawer and I want to customize it.
My Current Menu looks like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?android:attr/activatedBackgroundIndicator">
<group
android:id="#+id/DrawerMainGroup"
android:checkableBehavior="single"
android:background="?android:attr/activatedBackgroundIndicator"
>
<item
android:id="#+id/drawer_home"
android:checked="true"
android:icon="#drawable/ic_home"
android:title="#string/home"
/>...
I want to have another icon on this. Do you think it is possible?
I searched the Web and could not fin anything useful for me.
Both images will be dynamically loaded. For example:
I have a app where i can get videos,pictures etc. That is the first Icon. Next to this, there should be a icon if this site is on homescreen or not.
Like: (IconType)(IconOnHome) Text
I don't know if this is even possible. I found app:actionlayout already, but i am not sure if I could load different images in to the xml.

Android add buttons to ActionBar

I have a problem, in my app I need to add 2 buttons to the ActionBar, i change the menĂ¹ file in this way
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/navigation_drawer"
android:icon="#drawable/ic_drawer"
android:title="Drawer"
android:showAsAction="ifRoom" />
<item android:id="#+id/info"
android:icon="#drawable/ic_info_outline_white_24dp"
android:title="info"
android:showAsAction="ifRoom" />
</menu>
but my items are in the overflow button without the image , only the text , how can I do to take off from there and make images appear on ActionBar ? it would be possible to put one on the left and one to the right of the name of the app ?
You can use android:showAsAction="always" to make them always show on the ActionBar.

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

Android 3.0: Changing order of icons in the action bar

I am working with the Android 3.0.
I have in the action bar 3 items and one of them is the menu of the application, it also has sub-menu in it.
I want to change the order of the icons so the menu won't be in the right place, I want it to be between the two other items. I tried to change the order in the xml with no success.
Does anyone has an idea how to set the order?
Try setting android:menuCategory and android:orderInCategory for your menu items to set the ordering.
Example:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/launch_search"
android:icon="#android:drawable/ic_menu_search"
android:title="#string/search_programs"
android:menuCategory="container"
android:orderInCategory="2"
android:showAsAction="always" />
<item android:id="#+id/preferences_screen"
android:icon="#android:drawable/ic_menu_preferences"
android:title="#string/preferences" />
<item android:id="#+id/refresh"
android:icon="#drawable/ic_menu_refresh"
android:menuCategory="container"
android:orderInCategory="1"
android:title="#string/refresh_items"
android:showAsAction="ifRoom" />
</menu>
It will have the same effect as declaring launch_search -action as last, but this way you'll have your actions in the right order for 2.x and older devices while being able to control action ordering for 3.x -devices.
The menu will always go to the right, you cannot control its placement.

Android option menu - one menu item in a single row

I am trying to use option menus for my application . When I add 2 MenuItem it shown in a single row, but i need only one item in a row and other in next row. Please help me.
Thanks..
You cannot. The Android system handles how the options menu is laid out and there are no options to achieve what you want. You would have to make your own View, and then slide this up/down when the menu button is pressed.
tr this code
<item android:id="#+id/last_most_item"
android:orderInCategory="10"
android:title="#string/last_most_often" />
<item android:id="#+id/middle_most_item"
android:orderInCategory="7"
android:title="#string/middle_most_often" />
<item android:id="#+id/first_most_item"
android:orderInCategory="4"
android:title="#string/first_most_often" />
</group>
I'm not sure it's possible but try with the MenuInflater and a menu resource file.
In your menu resource file, try to embed each item in a separated <menu> element, something like this :
<menu>
<item>
<menu>
<item android:id="#+id/item1"
android:title="#string/item1" />
</menu>
</item>
<item>
<menu>
<item android:id="#+id/item2"
android:title="#string/item2" />
</menu>
</item>
</menu>
Maybe it will force the inflater to show the items in 2 separated lines, sorry I don't have the time to test it. If it's not working, replace the submenus with <group> elements and retest.

Categories

Resources