我們對Android開發非常新,所以如果這是很明顯的。
我們正在使用選項卡式視圖實現 Activity 。 我們所擁有的問題是標籤上的圖標和適當的顏色本身沒有正確顯示在 Jelly Bean ( 安卓 4.2 ) 上。 但是,它們在早期的API級別上可以正確顯示,比如 Gingerbread 。
請注意:我們最初使用過時的TabActivity類創建了視圖。 然而,就我所知道的,這樣做的"較新"方法不應該與舊的方法不同。 如果我錯了,請糾正我。
這是包含選項卡主機布局的xml:<?xml version="1.0" encoding="utf-8"?>
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/Black">
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
下面是相關的( 我希望) Activity 代碼:public class MainTabActivity extends FragmentActivity implements TabHost.TabContentFactory
private TabHost tabHost;
//other instance variables.. .
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
tabHost = (TabHost)findViewById(android.R.id.tabhost);
tabHost.setup();
TabSpec loginTabSpec = tabHost.newTabSpec(GlobalConstants.LOGIN_ACTIVITY);
loginTabSpec.setIndicator("Settings", getResources().getDrawable(R.drawable.ic_action_settings_gear));
loginTabSpec.setContent(this);
TabSpec mainTabSpec = tabHost.newTabSpec(GlobalConstants.MAIN_ACTIVITY);
mainTabSpec.setIndicator("Lone Worker", getResources().getDrawable(R.drawable.ic_action_settings_phone));
mainTabSpec.setContent(this);
tabHost.addTab(mainTabSpec);
tabHost.addTab(loginTabSpec);
}
這就是 Jelly Bean ( 錯誤版本) 上標籤本身的樣子:
最後,這是它應該看起來像( 在 Gingerbread 上。 好版本):
因這裡,選項卡的背景顏色是黑色( 當它正常的藍色顏色),但是很難從錯誤的屏幕快照中出現。 我希望這個問題在這裡得到了。 請告訴我是否有遺漏。 感謝你提前致謝 !