Android 操作栏选项卡上的黑色
我对我的应用程序中出现的一个奇怪的用户界面错误非常恼火,它只出现在android 4.1.2(真实设备)上 错误在于活动选项卡上的背景色为黑色(请参见下面的屏幕截图) 活动(选定)选项卡的背景颜色应为白色,非活动(未选定)选项卡的背景颜色应为灰色 虽然在我的styles.xml文件中,我清楚地设置了一个状态列表,当选项卡处于活动状态时,它可以以白色背景绘制,并且在android版本4.2.2及更高版本上运行良好 以下是my styles.xml:Android 操作栏选项卡上的黑色,android,android-fragments,tabs,android-actionbar,tabbar,Android,Android Fragments,Tabs,Android Actionbar,Tabbar,我对我的应用程序中出现的一个奇怪的用户界面错误非常恼火,它只出现在android 4.1.2(真实设备)上 错误在于活动选项卡上的背景色为黑色(请参见下面的屏幕截图) 活动(选定)选项卡的背景颜色应为白色,非活动(未选定)选项卡的背景颜色应为灰色 虽然在我的styles.xml文件中,我清楚地设置了一个状态列表,当选项卡处于活动状态时,它可以以白色背景绘制,并且在android版本4.2.2及更高版本上运行良好 以下是my styles.xml: <!-- Base applicatio
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">@style/TabText</item>
<!-- This is a White background -->
<item name="android:actionBarTabBarStyle">@style/TabBar</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabs</item>
</style>
<style name="TabBar" parent="android:style/Widget.Holo.Light.ActionBar.TabBar">
<!-- This is a White background -->
<item name="android:background">@color/white</item>
</style>
<!-- ActionBar tabs styles -->
<style name="MyActionBarTabs" parent="android:style/Widget.Holo.Light.ActionBar.TabView">
<!-- tab indicator -->
<item name="android:background">@drawable/tab_bar_background</item>
</style>
<style name="TabText" parent="android:style/Widget.Holo.Light.ActionBar.TabText">
<!-- This is a WHITE tab color -->
<item name="android:textColor">@color/selector_tab_text</item>
<item name="android:textAllCaps">false</item>
</style>
正如我所提到的,这段代码在android版本4.2.2(所选选项卡的白色背景)上非常有效
我错过什么了吗
谢谢您的时间。一些三星设备的颜色弄乱了。你在测试这样的测试吗?如果是,请尝试将所选选项卡的颜色从白色更改为黑色。谢谢大家的帮助。 我设法让我的标签栏正常工作,用以下代码替换我的可绘制列表(谷歌android版权):
此处提供了可拉拔电缆(xxhdpi)
(谷歌的代码和绘图)
回到问题本身:
为什么相同的旧代码在某些设备上有效而在其他设备上无效,这仍然是一个谜
在结束主题之前要添加一件事:通过从旧列表drawable中删除这部分代码,它可以工作=选中(激活)选项卡上的白色背景,但当然没有选中选项卡状态的底部指示器颜色
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#309CB9" android:width="3dp"/>
</shape>
</item>
我假设在同一层列表中有两个项目破坏了某些东西,并在4.2.x之前的“某些设备”上创建了错误行为这就是底部指示器颜色的样子:
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#309CB9" android:width="3dp"/>
</shape>
</item>
您需要添加实心透明填充,它将解决此问题,如下所示:
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
**<solid android:color="@android:color/transparent"/>**
<stroke android:color="#309CB9" android:width="3dp"/>
</shape>
</item>
****
谢谢Teodor的回答,是的,它是三星的……但我不明白将颜色从白色改为黑色如何解决这个问题。为一些设备干杯,他们的颜色弄乱了#000000是白色的#ffffff是黑色的,介于两者之间的都错了。你可能正在一台装有如此混乱的三星安卓系统的设备上进行测试。
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#309CB9" android:width="3dp"/>
</shape>
</item>
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
<stroke android:color="#309CB9" android:width="3dp"/>
</shape>
</item>
<item android:top="-5dp" android:left="-5dp" android:right="-5dp">
<shape android:shape="rectangle">
**<solid android:color="@android:color/transparent"/>**
<stroke android:color="#309CB9" android:width="3dp"/>
</shape>
</item>