Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
560 views
in Technique[技术] by (71.8m points)

android - Don't want icons on my TabWidget

I'm still learning about Android, and while playing around with TabHost and TabWidget, I can't help but notice that there's no option to turn off the icons.

It's eating up valuable space even when I don't actually set an icon into the TabSpec. Is there any way to reduce the height of the tab bar? It's really hard to find small icons (at 3 different sizes) that perfectly fits what I intended those tabs to contain. I have zero skills with graphics.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have this:

        TabHost tabHost = getTabHost();  // The activity TabHost

Add code to add tabs into tab host... and then finally

        tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 25;
        tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 30;
        tabHost.getTabWidget().getChildAt(2).getLayoutParams().height = 35;
        tabHost.getTabWidget().getChildAt(3).getLayoutParams().height = 50;

Which (if you do not have pics) results in this:alt text

It looks like 35 is a good number.. Perhaps it needs to be changed for different dpi.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...