When working with NavigationView there is a tools:showIn="navigation_view" on its menu.xml file which make its preview turn into a hamburger menu style and not a regular Toolbar action item.
Is there any other value we can provide to showIn that is default to Android platform itself? I know we can also provide a layout but what I am looking for is its equivalent on other navigation view like BottomNavigationView.
Related
I have used Google's solution for multiple back stacks in Navigation Component. I want to setup a custom AppBar at the activity level(Idea is to have a Toolbar, A FragmentContainerView, and BottomNavigationView)
This works fine except this sets the title of the Toolbar automatically (doesn't call any particular method in the file I have linked as far as I know) .
I want to build a custom toolbar which has a TextView with multiple colors(As in half of the title is black , other half is yellow).
Any solution how to build a custom toolbar in this solution would be greatly appreciated
You can read this document about handle navigation component back stack with appBar configuration
https://developer.android.com/guide/navigation/navigation-ui
and also you can watch this course for make custom toolbar
https://m.youtube.com/watch?v=e5_C9e_gKOM
I used bottom navigation bar on my app. And I also want to use a toolbar to use a search filter.
I know that I need a menu.xml to use a toolbar but I already made menu.xml to use the bottom navigation bar.
If i use a toolbar on my app, do i have to made a new menu.xml?
Though I included more instances in bottom navigation bar's menu.xml, I couldn't do anything
Both don't need to be the same name (menu.xml) and can have different names (eg: bottom_nav_menu.xml for navigation & top_menu.xml for toolbar)
I have an app, which have an action menu item on the right (2).
I need an ulterior menu in the left(1) or a button in the action bar, is that possible?
I attach a image.
enter image description here
You may create a custom toolbar. The standard height of a toolbar is 89dp.
To create a custom toolbar you should make your activity view container RelativeLayout. Then create a custom toolbar view (it may also be RelativeLayout) which height is 89dp. Then add your toolbar to the main container and set alignParentTop to true. So you have a custom flexible toolbar and you can add any view to it.
This way is very comfortable to use any custom views on your toolbar.
I also faced the same situation of customizing action bar. After a lot of searching I got the solution which is Toolbar.
Checkout: https://developer.android.com/training/appbar/setting-up
I think from now on, you should start using Toolbar as the default action bar for your apps. It provides high level of customization and material design features.
I'm trying to create an inline menu as part of a layout. In other words, I want a "three dots" menu overflow icon (such as the one in the below example), placed on its own somewhere in my layout, and upon clicking it a standard menu should pop up.
At first I tried embedding a Toolbar from the support library in my layout, and while it does result in the menu overflow icon being shown, it's not ideal for my situation; a toolbar is a wide component intended to include a title, sub-title, icon etc. I only need the menu icon and behavior. Also, I have failed to style the toolbar to my liking, including getting rid of the quite large margin around the menu overflow icon. It would make more sense to use a simpler component for just the menu then trying to make a Toolbar fit into my layout.
I know that Toolbar internally uses an ActionMenuView to implement the menu, so I then tried including an ActionMenuView in my layout, and attach a menu to it from code:
<LinearLayout ...>
<android.support.v7.widget.ActionMenuView
android:id="#+id/menu_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
...
ActionMenuView amv = (ActionMenuView)findViewById(R.id.menu_button);
getMenuInflater().inflate(R.menu.some_menu, amv.getMenu());
amv.setOnMenuItemClickListener(...)
This however only results in an invisible view. When using a Toolbar and writing the equivalent code to attach a menu to it, the menu overflow icon is automatically shown and can be clicked, but when using a stand-alone ActionMenuView I just cannot get it to work.
I even tried to hard-code the width and height to 50dp, and while the view is visible in Android Studio's layout preview window, it's not visible on device (hierarchy viewer shows its height to be zero).
Now, of course I guess I can create an ImageButton with the desired icon and manually implement a menu behavior on it, but surely there must be a simple way to get the existing component working?
I've changed Navigation Drawer with Navigation view and it works well.
I was using following code to make all items white in action bar :
<.item name="android:textColorPrimary">
The problem is Navigationview gives error if I use this code.
How this could be possible while both library were written by Google ?
PS : I work on Xamarin Android
Thanks
Do you mean to have a . before item?, I believe it should read <item name="android:textColorPrimary"> if I am not mistaken.
I think you are mixing things together now. Actionbar has nothing to do with the colors of the items in the NavigationView.
You should set the 'app:itemTextColor="#009688"' on the NavigationView to color the text of the items.
More on how to style the NavigationView you can find here: How to customize item background and item text color inside NavigationView?