ActionBarSherlock - How to set the padding of each actionbar's icon?
<style name="AppTheme" parent="Theme.Sherlock">
<item name="actionButtonStyle">@style/MyActionButtonStyle</item>
<item name="android:actionButtonStyle">@style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="Widget.Sherlock.ActionButton">
<item name="android:minWidth">32dip</item>
<item name="android:padding">0dip</item>
</style>
The default value of android:minWidth
for the ActionBar
buttons is 56dip
.
Don't forget to set @style/AppTheme
as the Activity
's theme.
Padding menu items in action bar sherlock
Check this link:
ActionBarSherlock - How to set the padding of each actionbar's icon?
The idea is to create a new theme which has a parent theme as Theme.Sherlock
and lower actionButtonStyle minWidth
attribute
<style name="MyTheme" parent="Theme.Sherlock">
<item name="actionButtonStyle">@style/MyActionButtonStyle</item>
</style>
<style name="MyActionButtonStyle" parent="Widget.Sherlock.ActionButton">
<item name="android:minWidth">28dip</item>
</style>
and apply this theme to your Activity in the manifest.
Padding between ActionBar's home icon and title
I adapted Cliffus answer and assigned the logo-drawable in my actionbar style definition, for instance like this in res/style.xml:
<item name="android:actionBarStyle">@style/MyActionBar</item>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#3f51b5</item>
<item name="android:titleTextStyle">@style/ActionBar.TitleText</item>
<item name="android:textColor">#fff</item>
<item name="android:textSize">18sp</item>
<item name="android:logo">@drawable/actionbar_space_between_icon_and_title</item>
</style>
The drawable looks like Cliffus' one (here with the default app launcher icon) in res/drawable/actionbar_space_between_icon_and_title.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/ic_launcher"
android:right="20dp"/>
</layer-list>
In the android_manifest.xml you can still set a different app icon (launcher icon on 'desktop'. Any different logo definition here are visible in activities without an action bar.
How to increase padding or margin between menu item icon and title in app toolbar?
I can't believe it took me so long to figure this out!
Eventually it occurred to me to use the Android Device Monitor. I went to Tools > Android > Android Device Monitor. When that started up, I clicked the package name of my app in the "Devices" tab and then I clicked the "Dump View Hierarchy for UI Automator" button (which looks like multiple phones stacked on top of each other) at the top of the "Devices" tab. This showed me the UI of my current screen. Then I could click on the "Refresh" button and discover that it was not two Views next to each other--it was one TextView with a DrawableLeft. I know, I know, that's obvious and should have been the first thing I thought of.
I had already found ActionBarSherlock - How to set the padding of each actionbar's icon? , but that didn't work for me. However, that gave me an example of something I needed--changing the ActionButton style.
Now that I knew it was a TextView with a DrawableLeft, I knew I needed to change DrawablePadding. That's the change I needed to make to styles.
To change the ActionButton theme I needed to add this to my styles.xml:
<style name="ActionButton" parent="@android:style/Widget.ActionButton">
<item name="android:drawablePadding">@dimen/action_button_padding</item>
</style>
dimen.xml:
<dimen name="action_button_padding">4dp</dimen>
Then a tweak to the Theme section of style.xml:
<style name="Theme.MyTheme"
parent="Theme.AppCompat.Light.NoActionBar">
<!-- other styles -->
<item name="android:actionButtonStyle">@style/ActionButton</item>
</style>
And it just works! No need to set a custom ActionProvider, edit the image to add spacing in the image file, or use extra XML files for each button.
Padding the actionbar up indicator image
As of API 15 the positioning of these elements are hard-coded into the layout resources. The only alternative you have would be to use a custom navigation layout to create your own and hide the built-in home navigation.
Related Topics
Android Manifest Restrict to Tablets
Android Alarmmanager Not Waking Phone Up
Where Do I Create and Use Scheduledthreadpoolexecutor, Timertask, or Handler
Android - How to Get Application Name? (Not Package Name)
How to Hide Android Soft Keyboard on Edittext
How to Import a Native Library (.So File) into Eclipse
Save Data and Change Orientation
Stop Asynctask Doinbackground Method
Firebase Cloud Messaging Send Click_Action
Classloader Referenced Unknown Path: /Data/App/
Apache Http Connection with Android 6.0 (Marshmallow)
Sqlite Exception No Such Column When Trying to Select
How Does One Use Basic Authentication with Volley on Android
Get File Path of Image on Android
Unzip a Zipped File on Sd Card in Android Application