Android ActionBar Tab Color

前端 未结 6 1320
伪装坚强ぢ
伪装坚强ぢ 2020-12-13 14:21

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 ?

6条回答
  •  生来不讨喜
    2020-12-13 14:50

    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)));
    

    To change tab bar background:

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

提交回复
热议问题