您的TabHost
设置如下:
convertView = mInflater.inflate(R.layout.datatab, parent, false);
TabHost tabs = (TabHost) convertView.findViewById(android.R.id.tabhost);
TextView microTitle = (TextView) convertView.findViewById(R.id.dataTabsTitle);
microTitle.setTypeface(fontBold);
tabs.setup();
TabSpec tab1 = tabs.newTabSpec("TabOne");
TabSpec tab2 = tabs.newTabSpec("TabTwo");
TabSpec tab3 = tabs.newTabSpec("TabThree");
tab1.setContent(this);
tab2.setContent(this);
tab3.setContent(this);
tab1.setIndicator(mContext.getString(R.string.dataOneTitle));
tab2.setIndicator(mContext.getString(R.string.dataTwoTitle));
tab3.setIndicator(mContext.getString(R.string.dataThreeTitle));
tabs.addTab(tab1);
tabs.addTab(tab2);
tabs.addTab(tab3);
tabs.addTab(tab4);
tabs.setup();
tabs.setOnTabChangedListener(this);
for (int i = 0; i < tabs.getTabWidget().getChildCount(); i++) {
View v = tabs.getTabWidget().getChildAt(i);
v.setBackgroundColor(mContext.getResources().getColor(android.R.color.white));
v.setBackgroundResource(R.drawable.orangetabs_tab_indicator_holo);
TextView tv = (TextView) tabs.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
tv.setTextColor(mContext.getResources().getColor(R.color.colorone));
tv.setTypeface(fontBold);
}
drawable是使用android holo colors生成的,如下所示:
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/orangetabs_tab_unselected_focused_holo"/>
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/orangetabs_tab_selected_focused_holo"/>
<!-- Pressed --><!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/orangetabs_tab_unselected_pressed_holo"/>
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/orangetabs_tab_selected_pressed_holo"/>
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/orangetabs_tab_unselected_pressed_holo"/>
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/orangetabs_tab_selected_pressed_holo"/>
虽然我使用v.setBackgroundColor(mContext.getResources().getColor(android.R.color.white));
为每个视图设置背景颜色,但在某些设备上,背景显示为黑色。
知道我做错了吗?
修改
正如评论中所建议的那样,我试图设置背景颜色(tabs.setBackgroundColor(mContext.getResources().getColor(android.R.color.white));
),但没有成功
它仍然显示如下: