Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

android - Define custom Logo for ActionBar (different than Logo) in XML?

I want to make a Actionbar_style.xml for my app and I would like to use a logo, different than my app logo / icon.

How to change it programmatcially is clear: Change logo that appears in Android ActionBar programatically But like this I would need to code this into each activity.

Is there a xml tag to define a custom Actionbarlogo in xml already?

my Customstyles.xml

<style name="CustomActionBar0" parent="android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@drawable/action_bg0</item>
</style>

android styles.xml seems not to have it...

<style name="Widget.ActionBar">
    <item name="android:background">@android:drawable/action_bar_background</item>
    <item name="android:displayOptions">useLogo|showHome|showTitle</item>
    <item name="android:divider">@android:drawable/action_bar_divider</item>
    <item name="android:height">?android:attr/actionBarSize</item>
    <item name="android:paddingLeft">0dip</item>
    <item name="android:paddingTop">0dip</item>
    <item name="android:paddingRight">0dip</item>
    <item name="android:paddingBottom">0dip</item>
    <item name="android:titleTextStyle">@android:style/TextAppearance.Widget.ActionBar.Title</item>
    <item name="android:subtitleTextStyle">@android:style/TextAppearance.Widget.ActionBar.Subtitle</item>
    <item name="android:progressBarStyle">@android:style/Widget.ProgressBar.Horizontal</item>
    <item name="android:indeterminateProgressStyle">@android:style/Widget.ProgressBar.Small</item>
    <item name="android:homeLayout">@android:layout/action_bar_home</item>
</style>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just set a value for the android:icon attribute

<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/AppTheme.ActionBarStyle</item>
</style>

<style name="AppTheme.ActionBarStyle" parent="android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@drawable/actionbar_background</item>
        <item name="android:titleTextStyle">@style/AppTheme.ActionBar.TitleTextStyle</item>
        <item name="android:icon">@drawable/ic_home</item>
        <item name="android:indeterminateProgressStyle">@style/IndeterminateProgress</item>
</style>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...