User3
User3

Reputation: 2535

ActionBar padding between elements:

I am trying to put padding between items in the action bar - specially my logo and the Navigation drawer icon, following is the style I am using:

<resources>

    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@android:color/transparent</item>
        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:icon">@drawable/logo_header</item>
        <item name="android:actionButtonStyle">@style/MyActionButtonStyle</item>
    </style>

    <style name="MyActionButtonStyle" parent="@android:style/Widget.ActionButton">
        <item name="android:minWidth">32dip</item>
        <item name="android:padding">12dp</item>
    </style>

</resources>

However these two dont seem to work:

<item name="android:minWidth">32dip</item>
<item name="android:padding">12dp</item>

Any idea what I am missing here?

Upvotes: 2

Views: 342

Answers (2)

j2emanue
j2emanue

Reputation: 62519

I'd make the logo into a drawable layer list instead and that way i can set its padding something like this:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:drawable="@drawable/my_main_icon"
        android:right="20dp"/>

</layer-list>

And if you use this please update your manifest to use this drawable as the main icon instead of the current.

update: it might be better to use this icon as a logo as per reading on stackOverFlow.
so in your manifest in application tag set android:logo="my_main_icon" , researching this still.

update: if you use logo i think you have to turn it on in the actionbar...

setDisplayUseLogoEnabled() Enables the use of an alternative image (a "logo") in the Action Bar, instead of the default application icon. A logo is often a wider, more detailed image that represents the application

Upvotes: 3

philx_x
philx_x

Reputation: 1776

i think the correct syntax here would be:

<item
...
android:layout_padding="12dp"
...
/>

Upvotes: 2

Related Questions