How to Set Background Color TabHost

前端 未结 3 1852
悲&欢浪女
悲&欢浪女 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 19:07

    tabHost.setOnTabChangedListener(new OnTabChangeListener() {
    
            public void onTabChanged(String arg0) {
                for (int i = 0; i < tab.getTabWidget().getChildCount(); i++) {
                    tab.getTabWidget().getChildAt(i)
                            .setBackgroundResource(R.drawable.tab_selected); // unselected
                }
                tab.getTabWidget().getChildAt(tab.getCurrentTab())
                        .setBackgroundResource(R.drawable.tab_unselected); // selected
    
            }
        });
    

    Try this method, I hope this will help you.

提交回复
热议问题