Reputation: 1623
First I have to say that I know this isn't correct anymore to the Google Guidelines. But still I need to know it.
I'm trying to Add the Android Icon in my ActionBar. Logo are not displayed in Actionbar, using AppCompat
This gave my the answer. But my problem now is that the logo is in the middle of the ActionBar. I want it in the left.
Code:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/MyActionBarLogo</item>
</style>
<style name="MyActionBarLogo" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="background">@color/background_material_dark</item>
<item name="logo">@drawable/icon</item>
<item name="displayOptions">useLogo|showHome</item>
</style>
Printscreen:
Anyone an idea? I have the feeling it's something stupid...
EDIT: Added Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ap.brecht.myapplication" >
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Upvotes: 0
Views: 2459
Reputation: 1623
Yeah I found the problem. It's really stupid!
The size of the icon was much to big! After changing it to 48 * 48 it works!
Upvotes: 2
Reputation: 854
why don't u use Toolbar?
I think in your case you should use toolbar.
Here is sample code...
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:theme="@style/Toolbar"
android:background="@color/primary"
app:theme="@style/Toolbar">
<TextView
android:id="@+id/toolbarTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="22dp"
android:textColor="@android:color/white"/>
</android.support.v7.widget.Toolbar>
that's my toolbar with textview in the middle of toolbar. You can put whatever you want instead of TextView I used Hope this will help u.
Upvotes: 2