嘿,所有我創建了一個tab layout填寫的Android標籤定製PIC和/或顏色
HelloTabWidget.java谷歌的〔實施例:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, ArtistsActivity.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("artists").setIndicator("Artists",
res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, AlbumsActivity.class);
spec = tabHost.newTabSpec("albums").setIndicator("Albums",
res.getDrawable(R.drawable.ic_tab_albums))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, SongsActivity.class);
spec = tabHost.newTabSpec("songs").setIndicator("Songs",
res.getDrawable(R.drawable.ic_tab_songs))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
我知道如何創建我的自己的圖標,而不是他們的灰色和白色的麥克風,但我無法弄清楚如何讓我的自定義圖標填充整個選項卡。當選中此選項卡時,它是淺灰色,中間是我的圖片,未選中深灰色,中間是我的圖片。我更喜歡用我自己的照片填滿整個標籤,並且更加知識淵博;我自己選擇用顏色來填充標籤。
這事我真的不喜歡關於Android。標準標籤根本不漂亮,如果選中,則無法再閱讀文本。像你想要做的那樣創建一個自定義的TabHost是非常困難的。 – 2011-01-07 22:38:31