How to Set Background Color TabHost

前端 未结 3 1878
悲&欢浪女
悲&欢浪女 2021-01-13 18:01

I need help, I\'m finding difficulty for change background color in a TabHost.

Original Image:

\"image1\

3条回答
  •  我在风中等你
    2021-01-13 18:59

    I am solved exactly the same problem with this method:

    private void setBackgroundColor() {
        int inactiveColor = getResources().getColor(R.color.inactive_tab);
        int activeColor = getResources().getColor(R.color.active_tab);
    
        // In this loop you will set the inactive tabs backgroung color
        for (int i = 0; i < tabWidget.getChildCount(); i++) {
            tabWidget.getChildAt(i).setBackgroundColor(inactiveColor);
        }
    
        // Here you will set the active tab background color
        tabWidget.getChildAt(tabHost.getCurrentTab()).setBackgroundColor(
                activeColor);
    }
    

提交回复
热议问题