0
我做了一個自定義的TabHost,我只想要在每個選項卡上沒有文字的圖像。我怎樣才能調整我的圖片選項卡的中心?請幫忙嗎?謝謝。這是MI java代碼: JAVAAndroid:在TabHost中對齊中心圖像
private void cargarTabHost() {
tabs=(TabHost)findViewById(android.R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec = tabs.newTabSpec("mitab1");
spec.setContent(R.id.tab1);
spec.setIndicator("", getResources().getDrawable(R.drawable.borrar));
tabs.addTab(spec);
spec = tabs.newTabSpec("mitab2");
spec.setContent(R.id.tab2);
spec.setIndicator("PLANO");
tabs.addTab(spec);
tabs.setCurrentTab(0);
RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
rllp.addRule(RelativeLayout.CENTER_IN_PARENT);
for (int i = 0; i < tabs.getTabWidget().getTabCount(); i++) {
tabs.getTabWidget().getChildAt(i).getLayoutParams().height = 75;
tabs.getTabWidget().getChildAt(i).findViewById(android.R.id.title).
setLayoutParams(rllp);
}
TabWidget tw = (TabWidget)tabs.findViewById(android.R.id.tabs);
View tabView = tw.getChildTabViewAt(0);
tabView.setBackgroundResource(Modulo.cargarColorPestanas(perfilObj.getColor()));
View tabView2 = tw.getChildTabViewAt(1);
tabView2.setBackgroundResource(Modulo.cargarColorPestanas(perfilObj.getColor()));
tabs.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
...
}
});
}
它不適合我 – Charlie