P
P
Pavel2015-01-29 17:57:25
Android
Pavel, 2015-01-29 17:57:25

How to display app logo in android actionbar?

778782135d1946e2bb938541209a0a52.jpg10b545cf9e4c42269b795452ad9ebe88.jpg
As you can see on the first skin, the logo is loaded into the manifest, but something breaks in the styles.
manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ex.p.thehackernewswallpaper" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/thn"
        android:label="@string/app_shortname"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".HomeActivity"
            android:label="@string/app_shortname"
            android:uiOptions="splitActionBarWhenNarrow">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

themes.xml
<resources>

    <style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MainActionBarStyle</item>
        <item name="actionBarStyle">@style/MainActionBarStyle</item>
    </style>

    <style name="MainActionBarStyle"
        parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@color/HackNewsDarkBlue</item>
        <item name="background">@color/HackNewsDarkBlue</item>
        <item name="android:icon">@drawable/thn</item>  <!-- не уверен насчет этого, все равно не работает -->
        <item name="icon">@drawable/thn</item>
    </style>
</resources>

The problem is solved when I use styles not from the support library (not Appcompat + android: prefix). However, the application and activities use the support library, so the application issues a crit. error (but on the background you can see that the logo has loaded).
Is it really impossible to display the logo in the actionbar with the Appcompat theme?
PS: after that, I'll ask one more question:
If you create an application from scratch and immediately run it on a piece of hardware, you still can't see the logo, but it renders with the logo in the preview. That is, it turns out that the render preview differs from the real picture, why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
anyd3v, 2015-01-29
@ProgramCodePav

getSupportActionBar().setDisplayShowHomeEnabled(true); set?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question