Android的动作条标签颜色颜色、动作、标签、Android

2023-09-12 08:50:31 作者:青烟离歌

我添加了动作条的标签我的应用程序。默认颜色的下划线是浅蓝色。我要如何改变颜色或样式选择的标签?

I have added ActionBar tabs to my application. Default color for that underline is light blue. How do I change that color or style for selected tab ?

推荐答案

对于任何人想改变动作条的颜色/背景code,你可以做这样的事情

For anyone wants to change actionbar color/background in code, you can do something like this

final ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.action_bar_bg));

要改变动作条下的标签栏的颜色:

To change the tab bar color under the actionbar:

actionBar.setStackedBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.color_brown_dark)));

要更改标签栏背景:

actionBar.setStackedBackgroundDrawable(getResources().getDrawable(
            R.drawable.coupon_header));