简体   繁体   English

在android中启动活动时,在标题栏中隐藏应用程序启动器图标

[英]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 (ie 72x72 icon) with text in the top corner of the activity. 我正在使用ActionBarSherlock,带有徽标而不是启动器图标(即72x72图标),活动的顶角有文本。

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? 有没有人知道隐藏启动器图标和标题标签的方法,以便在显示ActionBarSherlock之前它不显示? 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>

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM