Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android TabHost更改底部栏的颜色_Java_Android - Fatal编程技术网

Java Android TabHost更改底部栏的颜色

Java Android TabHost更改底部栏的颜色,java,android,Java,Android,搜索这个已经有一段时间了,努力让任何东西都能正常工作 我需要将蓝色底部栏的颜色更改为十六进制值,我已经更改了选项卡的背景颜色,但它没有更改TanHost上的蓝色。真的有可能改变这一点吗?我看到youtube把它做成了一个漂亮的红色,所以它一定是可行的!这是设置选项卡主机: 选项卡是由它们自己的类控制的片段 // set up the tabhost mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);

搜索这个已经有一段时间了,努力让任何东西都能正常工作

我需要将蓝色底部栏的颜色更改为十六进制值,我已经更改了选项卡的背景颜色,但它没有更改TanHost上的蓝色。真的有可能改变这一点吗?我看到youtube把它做成了一个漂亮的红色,所以它一定是可行的!这是设置选项卡主机:

选项卡是由它们自己的类控制的片段

// set up the tabhost
         mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
            mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
            mTabHost.addTab(mTabHost.newTabSpec("event").setIndicator("Event Locations",
                    getResources().getDrawable(R.drawable.ic_event_tab)),
                    EventFragment.class, null);
            mTabHost.addTab(mTabHost.newTabSpec("itin").setIndicator("Itinerary",
                    getResources().getDrawable(R.drawable.ic_itin_tab)),
                       ItineraryFragment.class, null);
            mTabHost.addTab(mTabHost.newTabSpec("info").setIndicator("Kendal Info",
                    getResources().getDrawable(R.drawable.ic_info_tab)),
                    KendalInfoFragment.class, null);

            mTabHost.getTabWidget().setBackgroundColor(Color.RED);

假设不推荐使用的库一如既往地工作,这是我用来给选项卡上色的过程。我只是在代码中设置了背景,如下所示,因为它在xml中无法直接访问:

 TabWidget tabs = (TabWidget)getTabWidget();            
        for (int i = 0; i<tabs.getChildCount(); i++) {
            RelativeLayout tab = (RelativeLayout) tabs.getChildAt(i);
            tab.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.tabindicator));
TabWidget tabs=(TabWidget)getTabWidget();
对于(int i=0;i
<?xml version="1.0" encoding="utf-8" ?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--  Non focused states --> 
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected" /> 
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected" /> 
<!--  Focused states  --> 
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_focus" /> 
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_focus" /> 
 <!--  Pressed  --> 
<item android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_press" /> 
<item android:state_pressed="true" android:drawable="@drawable/tab_press" /> 
</selector>