我的项目中有一个标签,我只是想知道当你将标签单击成你想要的其他颜色时是否可以改变橙色。我想将它改成其他颜色你可以通过xml改变它或者以编程方式?
xml代码是这样的:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
选择器:
<!-- Active tab -->
<item android:state_selected="true" android:state_focused="false"
android:state_pressed="false" android:drawable="@drawable/tab_bg_selected" />
<!-- Inactive tab -->
<item android:state_selected="false" android:state_focused="false"
android:state_pressed="false" android:drawable="@drawable/tab_bg_unselected" />
答案 0 :(得分:0)
以下是从不同答案中获取的一些代码:
View mIndicator = inflater.inflate(R.layout.tab_indicator_holo,
mTabHost.getTabWidget(), false); // this will inflate a layout, you can use whatever layout you want
TextView title1 = (TextView) mIndicator.findViewById(android.R.id.title); //so we add a title
title1.setText("TAB1"); // we bind the title
mTabsAdapter.addTab(mTabHost.newTabSpec("TAB1").setIndicator( mIndicator), F_GetGames.class, null); // we bind the inflated layout