enter image description here
How to i print text on bottom of Action bar logo
<item android:title="Customer Inquiry"
android:id="#+id/customer_inquiry"
app:showAsAction="always|withText"
android:icon="#drawable/customer_inqury"/>
i set text but its not visible...!
there is no such option for MenuItem, by design these items don't and shouldn't have any text. if you really need those labels you need to write own drawing class and use app:actionLayout or even whole custom Toolbar set for Activity with setSupportActionBar(..) in Activity
Related
I used navigation drawer to design the menu of my app for first time, I change the menu icon by my xml code but the icon in activity is showing like gray overlay i used itemIconTint but it not showing right. My icon have different colors how can i display my icon with all colors
My trip icon is showing gray as shown , and after setting itemIconTint all goes to orange color
Try Below code :
Programmatically
yourNavigationView.setItemIconTintList(null);
From XML
<android.support.design.widget.NavigationView
...
app:itemIconTint="#android:color/black"
... />
I want my menu items on the BottomNavigationBar to have text-only labels with no icon. Unfortunately, it looks like design_bottom_navigation_item.xml always has a 24x24dp space reserved for the icon, with no publicly-exposed way to set it to gone. And even after getting past that, the label layout is set to a layout_gravity of bottom|center_horizontal, and it doesn't look like there's a way to programatically set layout_gravity to centered.
What is the fastest, easiest way to achieve the goal of a text-only menu item on the bottom nav bar? I'm thinking I can do this by creating a custom version of the item layout, then subclassing BottomNavigationItemView, BottomNavigationMenuView, and BottomNavigationView to specify that custom layout... but that seems like an awful lot of work for one little change. Am I missing something simpler?
dont put iandroid:icon property to your item
Just use the code below. I tried hard to do this easy way but failed.Then I made an alternative. Just use transparent color instead of icon drawble
<item
android:icon="#android:color/transparent"
android:id="#+id/navigation_id"
android:title="title" />
Add this in your dimens file. Then you can add padding according to your navigation view size.
<dimen name="design_bottom_navigation_height"tools:override="true">30dp</dimen>
In my app I want to create a searchview within an actionbar. I've used the following code.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="#+id/autocomplete_search"
android:icon="#drawable/search_light"
android:title="#string/what_form_edit_text"
app:showAsAction="ifRoom|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView" /></menu>
With this code a search icons shows up in my activity. After clicking this icon the search view expands and aligns on the left side of my actionbar (the title is gone).
Now I want to achieve this behaviour when automatically expanding the searchview. I tried to change the values of showAsAction into "always" instead of "ifRoom|collapseActionView", but it's not working. The searchview gets expanded, but is aligned on the right side of the actionbar. Is there any way I am missing to align the searchview on the left side (without implementing my own toolbar and place the searchview within?). Thanks for any help :)
Try to use
app:showAsAction="ifRoom"
It should fix your issue.
I don’t know what the real name of this is, but I want to change the top menu for an image or button. Someone can tell me what the name is and how do that in my android aplication?.
something like it!!!
in your menu xml add this in the item tag android:icon="#drawable/youricon"
app:showAsAction="always"
If you mean the custom text, you can add custom vews in your toolbar. The toolbar is just a viewgroup where you can add views inside. See this as an example.
If you mean to add a custom image instead of the back arrow, you can switch it with the toolbar.setNavigationIcon(Drawable drawable) method.
If you want to display the default arrow, then try with this (after setting the toolbar).
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
Is there a way to position the title text for a menu item to the left of the icon rather than to the right in an ActionBar? So in:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/forward"
android:title="Begin"
android:icon="#drawable/ForwardArrow"
android:showAsAction="always"></item>
</menu>
It would appear "Begin ->" instead of "-> Begin"
While you can define things like android:actionButtonStyle in a theme and apply that to your activity, I am not aware that you can use that to turn around and affect the positioning of the image versus the text.
However, you can use android:actionLayout in your <item> element to replace the stock action button with something else of your own design. If you putter around the Android source and find where these action buttons come from, I suspect that you will find that they are styled Button objects using the compound drawable stuff to put an image alongside the text caption. Cloning that and switching the side for the image, then using that for your actionLayout, should work, at least in theory.