Android:在TabHost中对齐中心图像

Android:在TabHost中对齐中心图像,android,image,alignment,android-tabhost,Android,Image,Alignment,Android Tabhost,我已经做了一个自定义的TabHost,我只想在每个选项卡上显示没有文本的图像。如何对齐“我的图像”选项卡的中心?需要帮忙吗?非常感谢。这是mi java代码: JAVA private void cargarTabHost() { tabs=(TabHost)findViewById(android.R.id.tabhost); tabs.setup(); TabHost.TabSpec spec = tabs.newTabSpec("mitab1");

我已经做了一个自定义的TabHost,我只想在每个选项卡上显示没有文本的图像。如何对齐“我的图像”选项卡的中心?需要帮忙吗?非常感谢。这是mi java代码: JAVA

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) {

            ...
        }
    });
}
private void cargarTabHost(){
tabs=(TabHost)findviewbyd(android.R.id.TabHost);
tabs.setup();
TabHost.TabSpec spec=tabs.newTabSpec(“mitab1”);
规格设置内容(R.id.tab1);
spec.setIndicator(“,getResources().getDrawable(R.drawable.borrar));
tabs.addTab(spec);
规格=制表符NETABSPEC(“mitab2”);
规格设置内容(R.id.tab2);
规格设置指示器(“平面”);
tabs.addTab(spec);
tabs.setCurrentTab(0);
RelativeLayout.LayoutParams rllp=新的RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_父级,ViewGroup.LayoutParams.WRAP_内容);
rllp.addRule(父对象中的相对位置中心);
对于(int i=0;i
试试看,我还没试过,但希望能奏效

...
 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)
       .setVisibility(View.GONE);
    }
...
。。。
对于(int i=0;i