Подтвердить что ты не робот

Можем ли мы установить фоновое изображение на вкладки?

Можно ли установить фоновое изображение на вкладки, подобные этому?

alt text

4b9b3361

Ответ 1

Следующий код работал у меня:

 tabHost.getTabWidget().setBackgroundResource(R.drawable.tabhost_bg);

Ответ 2

попробуйте это

             getTabHost().addTab(getTabHost().newTabSpec("A")
                    //set the tab name
                    .setIndicator("A")
                    //Add additional flags to the intent (or with existing flags value).
                    .setContent(new Intent(this, A.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));      

            //for creating tab we need to pass tabSpec and tab name to setIndicator and pass intent to its 
                //setContent  to Tab Activity predefined method getTabHost then it will create tab
             getTabHost().addTab(getTabHost().newTabSpec("B")
                    //set the tab name
                        .setIndicator("B")

                         //Add additional flags to the intent (or with existing flags value).
                       .setContent(new Intent(this,B.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) );

getTabHost().addTab(getTabHost().newTabSpec("C")
                    //set the tab name
                        .setIndicator("C")

                         //Add additional flags to the intent (or with existing flags value).
                       .setContent(new Intent(this,C.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) );    


             getTabHost().getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.a);
 getTabHost().getTabWidget().getChildAt(1).setBackgroundResource(R.drawable.b);
 getTabHost().getTabWidget().getChildAt(2).setBackgroundResource(R.drawable.c);

Ответ 3

TabSpec generalTab = mTabHost.newTabSpec("general");
generalTab.setIndicator("General", getResources().getDrawable(android.R.drawable.ic_menu_preferences)).setContent(R.id.tabGeneral);

Я использовал утилиту default android drawable, которая может использовать то, что вы хотите

для установки фона tabhost

this.mTabHost = (TabHost)this.findViewById(R.id.tabHost);
    this.mTabHost.setBackgroundResource(R.drawable.back);