【问题标题】:Removing ActionBar (Tittle) splash screen with icon删除带有图标的 ActionBar (Tittle) 闪屏
【发布时间】:2014-04-22 09:08:09
【问题描述】:
刚刚开始使用操作栏进行开发。有这个问题。我已经根据需要自定义了操作栏(有点,仍然无法在左侧定位按钮:))。我已经从操作栏中删除了图标、后退按钮、标题。
问题是,当我启动应用程序时,标题栏(带有图标和标题)会闪烁一秒钟,然后出现自定义操作栏......
我怎样才能阻止这种飞溅?
我看到了一些答案,包括从 android 主题中删除 TittleBar,但是因为 TittleBar 和 ActionBar 基本上是同一件事,删除 TittleBar 会导致 ActionBar 消失。
【问题讨论】:
标签:
android
android-actionbar
【解决方案1】:
如果你想在一个 Activity 中删除你的 ActionBar,最好的处理方法是使用 Theme。
在你的 AndroidManifest 中,用你应用的 Theme 声明你的应用,你可以用一个 Theme 来声明 Activity:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="SplashActivity"
android:theme="@style/AppThemeNoTitle"
android:label="@string/app_name"/>
<!-- ... YOUR OTHERS ACTIVITIES -->
</application>
在您的 style.xml 中:
<!-- Application theme. -->
<style name="AppTheme" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>
<style name="AppThemeFullScreen" parent="AppTheme">
<item name="android:windowNoTitle">true</item>
</style>