Thursday 15 September 2011

java - Android TabHost change color of the bottom bar -


Looking for a while now and nothing is struggling to work.

I have to change the color of the hex value of blue stripe, I changed the background color of the tab, but it could not change the blue color on TanHost. Is it possibly possible to change it? I see that YouTube has made it a good red, so it should be possible in any way! This tabhost is installing:

Tabs are fragmented by their own class

  // tabhost mTabHost = (FragmentTabHost) findViewById (android.r installed) Id.tabhost); MTabHost.setup (this, getSupportFragmentManager (), RID. Retailbank); MTabHost.addTab (mTabHost.newTabSpec ("Event") setIndicator ("Location of Event", getResources () getDrawable (R.drawable.ic_event_tab), EventFragment.class, Null.); MTabHost.addTab (.. mTabHost.newTabSpec ("ITIN") setIndicator ("travel program", getResources () getDrawable (R.drawable.ic_itin_tab), ItineraryFragment.class, faucet); MTabHost.addTab (.. mTabHost.newTabSpec ("info") setIndicator ("Kendall information", getResources () getDrawable (R.drawable.ic_info_tab), KendalInfoFragment.class, null); . MTabHost.getTabWidget () setBackgroundColor (Color.RED);    

Believing the excluded library works as usual, as it should be , This is the process I have used in my tab color. I just set the code in the background, because it was not correctly accessible in XML: TabWidget tabs = (TabWidget) getTabWidget () ; (Int i = 0; i & lt; tabs.get childcount (); i ++) {Relative layout tab = (Relative layout) tabs.getChildAt (i); Tab.setBackgroundDrawable (. This.getResources () getDrawable (R.drawable.tabindicator));

The tabulator draoble is as follows:

   & Lt; Item android: state_focused = "false" Android: state_selected = "true" Android: state_pressed = "false" android: drawable = "@drawable / tab_schai" /> & Lt ;! - focused state - & gt; & Lt; Item android: state_focused = "true" android: state_selected = "false" Android: state_pressed = "false" android: drawable = "@ drawable / tab_focus" /> & Lt; Item android: state_focused = "true" android: state_selected = "true" Android: state_pressed = "false" android: drawable = "@ drawable / tab_focus" /> & Lt ;! - pressed - & gt; & Lt; Item android: state_selected = "true" Android: state_pressed = "true" android: drawable = "@ drawable / tab_press" /> & Lt; Item Android: state_pressed = "true" android: drawable = "@ drawable / tab_press" /> & Lt; / Selector & gt;   

There was only 9-patch image with the design color, however you can get the same effect using a standard color.

OR



No comments:

Post a Comment