画像を使用せずにAndroidでカスタマイズされたタブバーを作成するにはどうすればよいですか?このようなタブバーを作成する必要があります...
1575 次
3 に答える
2
私はstackoverflow自体で私の質問に対する答えを見つけました
次の質問でHardikGajjarが行った回答を参照してください。
于 2012-10-04T05:52:10.640 に答える
1
ビューをタブに関連付けることができます。
tabHost.newTabSpec("name").setIndicator(R.id.your_view)
于 2012-10-01T11:38:10.977 に答える
0
タブボタンごとにカスタムビューを作成する必要があり、カメラタブに対しては異なるビューを返します。私はこのようなものだと思います:
private void fillTabHost() {
setupTab(ONE, new Intent().setClass(this, Activity.class), "title",R.drawable.icon);
setupTab(TWO, new Intent().setClass(this, Activity.class), "title", R.drawable.icon);
setupTab(THREE, new Intent().setClass(this, Activity.class), "title",R.drawable.icon);
setupTab(FOUR, new Intent().setClass(this, Activity.class), "title",R.drawable.icon);
setupTab(FIVE, new Intent().setClass(this, Activity.class), "title",R.drawable.icon);
}
private void setupTab(final String tag, Intent intent, int label, int icon) {
View tabview = createTabView(tag, mContext, label, icon);
TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(intent);
mTabHost.addTab(setContent);
}
private static View createTabView(String tag, final Context context, final int text, final int icon) {
if(tag.equals("THREE")){
// TODO return your CAMERA view
}else{
View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
ImageView iv = (ImageView) view.findViewById(R.id.tabsIcon);
iv.setBackgroundResource(icon);
TextView tv = (TextView) view.findViewById(R.id.tabsText);
tv.setText(text);
}
return view;
}
これがお役に立てば幸いです。
于 2012-10-01T11:51:55.460 に答える