Reputation: 11
n the action bar only appears the title and the app icon is hide. What can I do to show the app icon?
I try many things for example the logo and a lot of others codes but anything work.
MyActivity:
package com.example.myapp;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.MenuItem;
public class MyActivity extends ActionBarActivity {
private InterstitialAd interstitial;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
My Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/icona"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity
android:name=".MyActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Main2Activity"
android:label="@string/title_activity_main2"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
My layout activity:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/fons"
tools:context=".Myctivity">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="25sp"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello world" />
</LinearLayout>
</RelativeLayout>
And in my main.xml I haven't any item
Upvotes: 1
Views: 521
Reputation: 1092
Try this
mActionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);
Upvotes: 0
Reputation: 51
See the answer here - it's not present in V21 as the style guidelines have changed: No App Icon on ActionBar
Upvotes: 1
Reputation: 306
You can set the icon app in your ActionBar from your manifest file. See these lines
<application
android:allowBackup="true"
android:icon="@drawable/icona"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
So @drawable/icona means that you have an icon which called "icona" in your drawable folders.
res/drawable-ldpi, res/drawable-mdpi ...
So add your icona.png file in folders above.
p.s I don't know what you mean when you said "the icon is an arrow" but i can imagine that you mean the up icon button. So this is not your app icon, your app icon located to the folders above. You can see more about the arrow in android Api here.
I hope to help you!
Upvotes: 0
Reputation: 61
You can access the home image view directly with
ImageView imgHome = (ImageView)findViewById(android.R.id.home);
You can then try changing background color, padding or checking visibility etc... to help debug
imgHome.setBackgroundColor(Color.parseColor("#ff0000"));
imgHome.setPadding(30, 0, 30, 0);
if (imgHome.getVisibility() == View.VISIBLE) {
// visible
} else {
// not visible
}
Good luck.
Upvotes: 0
Reputation: 5495
Try to do this after onCreate
getActionbar().setHomeButtonEnabled(true);
getActionbar().setDisplayHomeAsUpEnabled(true);
Upvotes: 1