rwe
rwe

Reputation: 119

how to set only a image (with out text) to tabs in tabhost android 1.6

i need to set a image to a each tab widget in a tab host. I set an image using host.addTab(host.newTabSpec("AAA") .setIndicator("A",getResources().getDrawable(R.drawable.my_tabselector));

but it not fit to the tab. (tab wiget is bigger than my image)

plase help me. Thanks

Upvotes: 0

Views: 1698

Answers (3)

Zar E Ahmer
Zar E Ahmer

Reputation: 34370

        TabHost tabHost = getTabHost();

        Intent intent;

        intent = new Intent(MainActivity.this, SecondActivity.class); 

        tabHost.addTab(tabHost.newTabSpec("").setIndicator("", getResources().getDrawable(R.drawable.home_selected)).setContent(intent));

        intent = new Intent(MainActivity.this, Calendar.class);  //2

        tabHost.addTab(tabHost.newTabSpec("").setIndicator("",getResources().getDrawable(R.drawable.calender_unselect)).setContent(intent));

do not write any text inside setIndicator("Tab text", getResource(). ...)

Upvotes: 0

Nik
Nik

Reputation: 7214

You can use this way ti hite tabs titles:

    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++)
    {
        View view = tabHost.getTabWidget().getChildAt(i);
        view.findViewById(android.R.id.title).setVisibility(View.GONE);
    }

Upvotes: 0

A. Abiri
A. Abiri

Reputation: 10810

Do this to make the tab only have an image:

tabHost.addTab(tabHost.newTabSpec("aaa").setIndicator("", getResources().getDrawable(R.drawable.my_tabselector)).setContent(R.id.my_tab_contentlayout));

Upvotes: 1

Related Questions