TabWidget白色前景色?
我不知道我做了什么,但有一段时间我的 TabWidget 有白色选项卡,看起来非常漂亮。我从来没有在我的项目中设置主题或背景/前景色。下次我编译它时,它又恢复为灰色选项卡。我的应用程序使用默认的深色主题。即使我将应用程序主题设置为浅色,选项卡仍然是灰色的。很明显,是其他东西改变了标签的颜色。有人知道该怎么做吗?
I don't know what I did but for a period of time my TabWidget had white colored tabs which looked really nice. I never set a theme or background/foreground color in my project at all. The next time I compiled it it reverted back to the gray tabs. My application is using the default dark theme. Even if I set the application theme to light, the tabs are still gray. So obviously it was something else that changed the tabs' color. Anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于 Android 1.6 的浅色主题中的错误(选项卡指示器文本为白色),我遇到了问题。我能够按如下方式覆盖默认主题:
styles.xml
:然后我只需通过添加
android将该主题应用到我的应用程序: theme="@style/MyTheme"
到我的AndroidManifest.xml
的
元素。I was having a problem due to a bug in Android 1.6's light theme (tab indicator text is white). I was able to override the default theme as follows:
styles.xml
:Then I just apply that theme to my application by adding
android:theme="@style/MyTheme"
to the<application />
element of myAndroidManifest.xml
.检查我的这个答案:选项卡小部件中的背景忽略缩放
也可以参考
android.graphics.drawable
package在您的代码中,您可以像这样设置选项卡的背景:
Check this answer of mine: Background in tab widget ignore scaling
You can also refer to the
android.graphics.drawable
packageIn your code, you can set the background for your tabs like this:
在
public void onCreate(Bundle savingInstanceState)
中比在侦听器中:
public void onTabChanged(String tabId) {
设置选项卡颜色();
最后是设置前景和背景的函数:
in the
public void onCreate(Bundle savedInstanceState)
than in the listener:
public void onTabChanged(String tabId) {
setTabColor();
finally the function, which set the foreground and the background too:
在 onCreated() 中:
In onCreated() :