Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the padding or margin of the action bar icon or logo in XML theme?

how to change the top and bottom padding or margin of the action bar icon or logo space by using XML theme?

<style name="Theme.Whycheck" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarItemBackground">@drawable/selectable_background_whycheck</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.Whycheck</item>
    <item name="actionModeBackground">@drawable/cab_background_top_whycheck</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_whycheck</item>

            <!-- Light.DarkActionBar specific -->
    <item name="actionBarWidgetTheme">@style/Theme.Whycheck.Widget</item>

</style>

<style name="ActionBar.Solid.Whycheck" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="background">@drawable/ab_solid_whycheck</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_whycheck</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_whycheck</item>
</style>

<style name="ActionBar.Transparent.Whycheck" parent="@style/Widget.AppCompat.ActionBar">
    <item name="background">@drawable/ab_transparent_whycheck</item>
</style>

<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Whycheck.Widget" parent="@style/Theme.AppCompat">
</style>

Provided my styles.

like image 726
Shawn Thye Avatar asked Sep 10 '13 15:09

Shawn Thye


People also ask

What is the difference between a Toolbar and an action bar?

An Action bar is traditionally a part of an Activity opaque window decor controlled by the framework but a Toolbar may be placed at any level of nesting within a view hierarchy. The toolbar provides more feature than ActionBar . A Toolbar may contain a combination of elements from start to end.

What is androidx appcompat Widget Toolbar?

androidx.appcompat.widget.Toolbar. A standard toolbar for use within application content. A Toolbar is a generalization of action bars for use within application layouts.

What is the use of Toolbar in android?

In Android applications, Toolbar is a kind of ViewGroup that can be placed in the XML layouts of an activity. It was introduced by the Google Android team during the release of Android Lollipop(API 21). The Toolbar is basically the advanced successor of the ActionBar.


1 Answers

You can try to create a new style for your icon in action bar like this : *Add this code in your styles.xml

    <!-- style for Action Bar -->
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBarView">
    <item name="android:background">@drawable/actionbar_tab_bg</item>
    <item name="android:paddingLeft">32dp</item>
    <item name="android:paddingRight">32dp</item>
</style>

*add your style to the UI action bar .

Also you can see this exemple customizing-action-bar

like image 161
wSakly Avatar answered Oct 19 '22 06:10

wSakly