动作条带NoTitleBar Theme.Holo.Light [英] ActionBar with NoTitleBar Theme.Holo.Light
问题描述
我有一个Android应用程序标签。我不想别的以外,以在屏幕的顶部显示的选项卡。
I have an Android tabbed app. I don't want anything else other than the tabs to be displayed at the top of the screen.
这工作好了,唯一的问题是,启动应用程序,很短的瞬间&LT时; 1秒,我可以看到与应用程序启动器图标的标题栏。
This works alright, the only problem is that, when launching the app, for a short moment < 1sec, I can see the title bar with the application launcher icon.
为什么会出现这种情况,是有办法prevent呢?
Why is this happening, is there a way to prevent this?
styles.xml
styles.xml
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
</style>
<style name="CustomActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">@style/NoTitleText</item>
<item name="android:subtitleTextStyle">@style/NoTitleText</item>
<item name="android:icon">@android:color/transparent</item>
</style>
<style name="NoTitleText">
<item name="android:textSize">0sp</item>
<item name="android:textColor">#00000000</item>
</style>
</resources>
AndroidManifest.xml中
AndroidManifest.xml
<activity
android:name="com.example.nfcproducttracing.ProductTracer"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:launchMode="singleTask">
这使我的标签文字白色和隐约可见。
This makes my tab text white and barely visible.
推荐答案
要prevent这一点,你必须使用XML文件中定义的样式insted的在您的onCreate方法都设定好了。
To prevent this you must use styles defined in xml file insted of seting everything in your onCreate method.
在此行中的code为execued
actionBar.setDisplayOptions(0,ActionBar.DISPLAY_SHOW_TITLE);
您的申请已经显现。
Before this line in code is execued
actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
your application is already visible.
试试这个:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="actionBarStyle">@style/CustomActionBarStyle</item>
</style>
<style name="CustomActionBarStyle" parent="@style/Widget.Holo.ActionBar">
<item name="titleTextStyle">@style/NoTitleText</item>
<item name="subtitleTextStyle">@style/NoTitleText</item>
<item name="icon">@android:color/transparent</item>
</style>
<style name="NoTitleText">
<item name="textSize">0sp</item>
<item name="textColor">#00000000</item>
</style>
</resources>
这篇关于动作条带NoTitleBar Theme.Holo.Light的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!