I've bottom menu bar that has 4 items from which one has to look differently (not depending on which item is selected/not). One item has to have bigger icon size.
Currently I'm styling my elements like this:
<style name="BottomNavigationView">
<item name="itemIconTint">#color/gray</item>
<item name="itemIconSize">26dp</item>
</style>
However, itemIconSize is affecting all menu items and not one specific. How to change icon size for specific menu item?
Related
I am trying to increase the size of the popup menu items in my toolbar's overflow menu. I've managed to increase the text size with the following in the base application theme.
<item name="android:textAppearanceLargePopupMenu">#style/menu_item</item>
And the following style.
<style name="menu_item" parent="Base.TextAppearance.AppCompat.Widget.PopupMenu.Large">
<item name="android:textSize">#dimen/text_regular</item>
</style>
Now, however, I'm stuck trying to get the padding right, as the items appear too close together, as well as there is very little space on either edge of the popup menu overall.
Popup Menu:
Things I have tried:
Adding padding to the menu_item style.
Adding various different style items to the base theme with the desired padding.
actionButtonStyle: No effect.
popupMenuStyle: No effect.
listMenuViewStyle: No effect.
Adding the following to the base theme. This did work to separate the items from each other, however the side padding obviously remained unchanged, and as a result looked disproportionate.
<item name="android:listPreferredItemHeightSmall">64dp</item>
I have an application with a lot of activities, that all use the same theme:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#aaa</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Activities all have action bar looking like by the lines of:
What I just can't figure out is, how to color action buttons (pencil on the right) to black.
Essentially I want to have white action bar (on screenshot is white just for action button to be visible) with black title, back arrow and action buttons, but I don't want to add Toolbar view to every activity I have.
So, is there a way to color action buttons black by XML?
Create vector icons for your menu items and set their color to black (in your case you won't need to set their color as they are black by default). To create vector asset go to File - New -Vector Asset.
You can also download an icon from the internet as svg file and import it through vector asset creating dialog.
The list of default icons is also available here.
i'm using actionbarsherlock for my actionbar. I have a sliding menu and searchview. when the application get launches, it will automatically pick the up navigation icon from style.xml file.
When the search menu gets expanded, the up navigation icon will not get changed, it will be still looking like 3 line slider menu. How to change the up navigation icon when searchview is expanded?. I have represented the flow in below image.
Create custom back button theme with parent of your custom theme.
<style name="MyThemeForSearch" parent="#style/MyCustomTheme">
<item name="android:homeAsUpIndicator">#drawable/my_back_indicator_for_search</item>
</style>
Set theme in runtime when Search is expanded., i.e onClick
setTheme(R.style.MyThemeForSearch);
check your layout drawable's whether you have set an image like 3 liner slide menu
when you create navigation drawer it automatically sets default image which will be loaded representing 3 liner slide like you mentioned change your ic_drawer.png image and replace image with what icon you wish.
also you might go check changing your theme
> <style name="Theme.MyFancyTheme" parent="android:Theme.Holo">
> <item name="android:homeAsUpIndicator">#drawable/my_fancy_up_indicator</item>
> </style>
Our app uses Action Bar Sherlock, and it has a theme like such:
<style name="Theme.MyApp.Default" parent="#style/Theme.Sherlock.Light">
<item name="actionButtonStyle">#style/MyApp.SherlockActionBar.Light.ActionButton</item>
<item name="android:actionButtonStyle">#style/MyApp.SherlockActionBar.Light.ActionButton</item>
</style>
<style name="MyApp.SherlockActionBar.Light.ActionButton" parent="#style/Widget.Sherlock.Light.ActionButton">
<item name="android:maxHeight">20dp</item>
<item name="android:maxWidth">20dp</item>
</style>
Where Theme.MyApp.Default is the default theme for the app.
I need to set the icons for the action buttons (#2 on this image) to be a specific size. When I set the height/width/scaleX/scaleY/scaleType/padding properties however, the icon on the button still maintain what looks like their pixel size. The text part of the action button does seems to adhere to the setting though. Could it just be a compound drawable on a textview?
How can I set the size of the icon on the action bar?
Action bar icons for phones should be 32x32 dp.
Action bar icons are graphic buttons that represent the most important actions people can take within your app. Each one should employ a simple metaphor representing a single concept that most people can grasp at a glance.
you refer that link here
Have you cleaned your project and then run?
and you can specify action item height in main.xml(actionbar menu layout ) also though contrl space wont wrk its like normal height prperty.
whenever changing styles you have to clean and run the project
More and more evidence points to the fact that the menu on the action bar is a compound drawable. (Setting the property android:drawablePadding moves the icon from the text.) And seeing that you can't scale the image in XML for a compound drawable, this doesn't seem possible at the moment.
I'm having real difficulty doing anything to the overflow menu in actionbar sherlock.
Ideally, I would like to use a custom TextView for each item in order to set a different font on it and change the colour of the pressed state.
I have tried (all without success):
Changing The Style Of Actionbar Overflow
Actionbar styled overflow menu items
listview as action overflow in sherlock actionbar
https://groups.google.com/forum/#!msg/actionbarsherlock/5lHOKNlXn_4/f9XicMXbFFAJ
My app will have different fragments, all extending BaseFragment with different items in the overflow menu. I'm also using the v4 support package. I'm creating my menu like this:
#Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.activity_borrow, menu);
}
activity_borrow.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/menu_filter"
android:title="test"
android:orderInCategory="100"
android:showAsAction="never"
/>
</menu>
My app uses a theme that inherits from Theme.Sherlock.
How can I used a custom view inside that menu? Or at the very least, how can I change the default blue pressed state?
To change the colors of the overflow list items, add two items to your application theme which is usually defined in res/values/styles.xml:
<item name="android:dropDownListViewStyle">#style/DropDownListView</item>
<item name="dropDownListViewStyle">#style/DropDownListView</item>
In that same file, add the style that you have just assigned:
<style name="DropDownListView" parent="#style/Widget.Sherlock.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background</item>
</style>
And finally create a selector drawable selectable_background.xml in the drawable folder, containing this:
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="#android:integer/config_mediumAnimTime" >
<item android:state_pressed="false" android:state_focused="true" android:drawable="#color/focussed_color" />
<item android:state_pressed="true" android:drawable="#color/pressed_color" />
<item android:drawable="#android:color/transparent" />
</selector>
Finally, define the colors which are usually placed in colors.xml:
<resources>
<color name="pressed_color">#FF8E4067</color> <!-- your purple tone already ;) -->
<color name="focussed_color">#DD8E4067</color>
</resources>
In my app, I used the "ActionBar Style Generator" as baboo suggested, which handles everything for you conveniently. For this answer, I just extracted and simplified the parts that I think make up the overflow menu styling.
I think there is some mystery about the effects of styling three different items:
From my understanding, android:dropDownListViewStyle includes the
overflow menu that hides behind the "three dots" in the ActionBar.
Not to be confused with android:actionDropDownStyle, which is used to the style the app navigation dropdown in case you used actionBar.setNavigationMode(NAVIGATION_MODE_LIST)
However, some Android devices with a hardware menu button (e.g. the Nexus S or Galaxy S3 Mini)
don't display the "three dots" but an overlay menu that slides in from
the bottom of the screen if the hardware menu button is clicked. android:popupMenuStyle is the correct attribute to style this.
Again, this is only as far as I can remember from my own app development.
Also, make sure to check that no other style files (e.g. folders with configuration qualifiers) overwrite the styles that you have just defined.
All in all, I understand that this would only change the background color of the list items. To use a completely custom view in there, you might create a custom spinner view, add a dummy button with a "three dots" icon to your ActionBar and open the spinner on click.