When i append tools:showIn="navigation_view" to my code it's not showing. But in video which i watched from Youtube this is working fine. What is the problem? Also I can't add library called
<?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:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_home"
android:icon="#drawable/ic_main_home"
android:title="#string/home" />
<item
android:id="#+id/nav_timetable"
android:icon="#drawable/ic_subject_timetable"
android:title="#string/timetable" />
<item
android:id="#+id/nav_ogrnot"
android:icon="#drawable/ic_ogrnot"
android:title="#string/ogrnot" />
<item
android:id="#+id/nav_yemek_menu"
android:icon="#drawable/ic_yemek_menu"
android:title="#string/yemek_menu" />
<item
android:id="#+id/nav_homework"
android:icon="#drawable/ic_homework"
android:title="#string/homework" />
</group>
<item android:title="#string/optional">
<menu>
<item
android:id="#+id/nav_to_do_list"
android:icon="#drawable/ic_to_do_list"
android:title="#string/to_do_list" />
<item
android:id="#+id/nav_logout"
android:icon="#drawable/ic_logout"
android:title="#string/logout" />
</menu>
</item>
</menu>
I had the same issue with my code. The first thing I did was to delete my already created menu file (Android resource file) and start the process from the top.
Secondly, after creating the menu resource file, on a new line, after typing (tool:), press alt+enter to add this automatically for you... xmlns:tools="http://schemas.android.com/tools"... Then you can go ahead to type in tools:showIn=".....".
To know if this works, in line of code in tools:showIn, when typing the name in the quotes, just type "na'... if there are other popups or suggestions, then you're good to go.
Hope this helps.
Related
I want to make a menu on my app's top like which showed me in the AS's xml, but in Android 6.0,it's on the bottom. How can I solve this problem? Thanks.
I have tried many methods like change my code, add the android:showAsAction='always', but it doesn't work.
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/menu_new_folder"
android:title="#string/menu_create_folder" />
<item
android:id="#+id/menu_export_text"
android:title="#string/menu_export_text"/>
<item
android:id="#+id/menu_sync"
android:title="#string/menu_sync"/>
<item
android:id="#+id/menu_setting"
android:title="#string/menu_setting" />
<item
android:id="#+id/menu_search"
android:title="#string/menu_search"/>
Create menu like this -
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/action_more"
android:orderInCategory="1"
android:icon="#drawable/ic_menu_dots"
android:title="more"
app:showAsAction="always">
<menu>
<item
android:id="#+id/menu_new_folder"
android:title="#string/menu_create_folder" />
<item
android:id="#+id/menu_export_text"
android:title="#string/menu_export_text"/>
<item
android:id="#+id/menu_sync"
android:title="#string/menu_sync"/>
<item
android:id="#+id/menu_setting"
android:title="#string/menu_setting" />
<item
android:id="#+id/menu_search"
android:title="#string/menu_search"/>
</menu>
</item>
</menu>
And in your activity's onCreateOptionMenu add this -
menu.findItem(R.id.action_more).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)
I'm setting the image as icon but its showing grey icon not the image,
This #drawable/image_second is the image I want to use as icon.
<?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:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_home"
android:icon="#drawable/image_second"
android:title="#string/menu_home" />
<item
android:id="#+id/nav_gallery"
android:icon="#drawable/ic_menu_gallery"
android:title="#string/menu_gallery" />
<item
android:id="#+id/nav_slideshow"
android:icon="#drawable/ic_menu_slideshow"
android:title="#string/menu_slideshow" />
<item
android:id="#+id/nav_tools"
android:icon="#drawable/ic_menu_manage"
android:title="#string/menu_tools" />
</group>
<item android:title="Communicate">
<menu>
<item
android:id="#+id/nav_share"
android:icon="#drawable/ic_menu_share"
android:title="#string/menu_share" />
<item
android:id="#+id/nav_send"
android:icon="#drawable/ic_menu_send"
android:title="#string/menu_send" />
</menu>
</item>
</menu>
after running the code,I get this,
please tell what to do and why its happening..
As always thanks a lot..
You can do so programmatically using
NavigationView.setItemIconTintList.
yourNavigationView.setItemIconTintList(null);
Also If you want to change the tint of other icons use this
In XML
<android.support.design.widget.NavigationView
...
app:itemIconTint="#android:color/black"
... />
Try removing the item icon tint.
mNavigationView.setItemIconTintList(null);
I have problem with actions on Toolbar in my Android app.
I have a group with some actions with app:showAsAction="ifRoom" attribute. Everything works fine if there are fewer than 4 items with ifRoom. But when I add fourth item, then all the items disappear from toolbar.
It works fine:
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:id="#+id/group_paint"
android:orderInCategory="1"
app:showAsAction="ifRoom">
<item android:id="#+id/action_layers"
android:icon="#drawable/ic_layers_white_24dp"
android:title="#string/action_layers"
android:orderInCategory="3"
app:showAsAction="ifRoom"/>
<item android:id="#+id/action_tool"
android:icon="#drawable/ic_properties_white_24dp"
android:title="#string/action_tool"
android:orderInCategory="4"
app:showAsAction="ifRoom" />
<item android:id="#+id/action_action1"
android:icon="#drawable/ic_action1_white_24dp"
android:title="#string/action_1"
android:orderInCategory="7"
app:showAsAction="ifRoom" />
<item
android:id="#+id/action_settings"
android:icon="#drawable/ic_settings_white_24dp"
android:title="#string/action_settings"
android:orderInCategory="7"
app:showAsAction="never" />
</group>
</menu>
Unexpected result:
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:id="#+id/group_paint"
android:orderInCategory="1"
app:showAsAction="ifRoom">
<item android:id="#+id/action_layers"
android:icon="#drawable/ic_layers_white_24dp"
android:title="#string/action_layers"
android:orderInCategory="3"
app:showAsAction="ifRoom"/>
<item android:id="#+id/action_tool"
android:icon="#drawable/ic_properties_white_24dp"
android:title="#string/action_tool"
android:orderInCategory="4"
app:showAsAction="ifRoom" />
<item android:id="#+id/action_action1"
android:icon="#drawable/ic_action1_white_24dp"
android:title="#string/action_1"
android:orderInCategory="7"
app:showAsAction="ifRoom" />
<item android:id="#+id/action_action2"
android:icon="#drawable/ic_action2_white_24dp"
android:title="#string/action_2"
android:orderInCategory="8"
app:showAsAction="ifRoom" />
<item
android:id="#+id/action_settings"
android:icon="#drawable/ic_settings_white_24dp"
android:title="#string/action_settings"
android:orderInCategory="7"
app:showAsAction="never" />
</group>
</menu>
What I would like to see is: three actions on toolbar and the fourth in the overflow menu.
You are using the <group> element to treat the items as a group. If you do not want to treat the items as a group (e.g., you want them to appear in the action bar individually based upon available space), get rid of the <group> element.
How can i expand the actionbar like PlayNewsstand application and the image below :
What i am looking for found it here.
For your concern try using this in your manifest file ..
yourapp:showAsAction="ifRoom"
Ex:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
yourapp:showAsAction="ifRoom" />
...
</menu>
Complete reference :: http://developer.android.com/guide/topics/ui/actionbar.html
I want to create a customized submenu where i can add an "about page" to my application. So my submenu would just be a text view with a bunch of info. Im currently defining my menu in XML. Any help or links would be great, thanks!!!
<?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/settings_menu"
android:title="Settings" />
<item android:id="#+id/about_menu"
android:title="About">
<menu>
<item android:id="#+id/about_submenu"
android:title="Tip Message" />
</menu>
</item>
<item android:id="#+id/quit_menu"
android:title="Quit" />
</menu>
Also just out of curiosity, how would i define a more complex custom submenu, like one that takes user input from a keyboard.
I think it's easier to make something look like a menu. Try Activity with #android:drawable/menu_submenu_background as a background for example.