Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide application launcher icon in title bar when activity starts in android

I've searched SO but not found similar questions as I'm not sure how to phase it in a sentence. I am using ActionBarSherlock, with a logo instead of the launcher icon (i.e. 72x72 icon) with text in the top corner of the activity.

When the activity loads for the first time, for a fraction of a second. I see the launcher icon and label defined in the manifest (as below), before the action bar appears with the logo. This home activity is very simple, so its not doing any additional loading which could cause a delay.

<application
    android:hardwareAccelerated="true"
    android:icon="@drawable/launcher_icon"
    android:label="@string/app_name"
    android:screenOrientation="portrait" >

    <activity
        android:name=".SplashScreenActivity"
        android:label="@string/app_name"
        android:logo="@drawable/ab_logo"
        android:theme="@android:style/Theme.Light.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".HomeActivity"
        android:label="@string/homeitle"
        android:logo="@drawable/ab_logo"
        android:theme="@style/MyTheme" >
    </activity>

 </application>

I can make the text "disappear" by styling it to be the same colour as the background, but i cant find a way to remove/hide the launcher icon from the activity.

I have setup a splashscreen activity (as in manifest above), which just loads my home activity where the issue occurs. This does help, but sometimes the issue still occurs when loading the activity.

public class SplashScreenActivity extends Activity
{
   @Override
   public void onCreate(Bundle savedInstanceState)
   {
        super.onCreate(savedInstanceState);
   }

   @Override
   public void onResume()
   {
       super.onResume();
       Intent i = new Intent(getBaseContext(), HomeActivity.class);
       startActivity(i);
       finish();
   }
}

Does anyone know of a way to hide the launcher icon & title label, so that it doesn't show up prior to ActionBarSherlock being displayed? Ideally so a splash screen is not needed, as there are several ways to access the activity which would avoid the splashscreen shown above.

--- Update My Theme File ----

   <style name="MyTheme" parent="Theme.Sherlock.ForceOverflow">
    <item name="android:windowBackground">@color/white</item>
    <item name="android:actionBarStyle">@style/MyTheme.ActionBar</item>
    <item name="android:actionMenuTextColor">@color/white</item>
    <item name="actionBarStyle">@style/MyTheme.ActionBar</item>
    <item name="actionMenuTextColor">@color/white</item>
</style>

<style name="MyTheme.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@color/blue</item>
    <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
    <item name="android:displayOptions">showHome|useLogo</item>
    <item name="displayOptions">showHome|useLogo</item>
    <item name="background">@color/blue</item>
    <item name="titleTextStyle"> @style/MyTheme.ActionBar.TitleTextStyle</item>
</style>

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/blue</item>
</style>
like image 345
JonWillis Avatar asked Jul 11 '12 10:07

JonWillis


1 Answers

Fixed it by adding icon to the style, which is the same as the logo. This overrides the launcher icon.

    <style name="MyTheme.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
      <item name="android:background">@color/infostop_blue</item>
      <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
      <item name="android:displayOptions">showHome|useLogo</item>
      <item name="displayOptions">showHome|useLogo</item>
      <item name="android:icon">@drawable/ab_logo</item>
      <item name="icon">@drawable/ab_logo</item>
      <item name="background">@color/blue</item>
      <item name="titleTextStyle"> @style/MyTheme.ActionBar.TitleTextStyle</item>
    </style>
like image 140
JonWillis Avatar answered Sep 19 '22 19:09

JonWillis