[Solved] Changing text size on a tab?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

[Solved] Changing text size on a tab?

Postby sandis84 » Tue Sep 29, 2009 1:06 pm

So I have a layout like this:

http://developer.android.com/guide/tuto ... widget.png

What I want to do is to change the text "TAB 1" to a smaller text size. I have experimentet a whole lot with themes and extending classes, but I am at a loss. Could someone offer advice?

regards
Per Sandström
Last edited by sandis84 on Wed Oct 07, 2009 8:34 am, edited 1 time in total.
sandis84
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Fri Aug 07, 2009 3:54 pm

Top

Postby konic » Tue Oct 06, 2009 4:49 pm

konic
Developer
Developer
 
Posts: 32
Joined: Mon Aug 24, 2009 3:16 pm

Postby konic » Tue Oct 06, 2009 5:39 pm

OK,
Now I know that I was wrong.
Here is the piece of code how to do it:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. TabWidget tw = getTabWidget();
  2. for (int i=0; i<tw.getChildCount(); i++) {
  3.     RelativeLayout relLayout = (RelativeLayout)tw.getChildAt(i);
  4.     TextView tv = (TextView)relLayout.getChildAt(1);
  5.     tv.setTextSize(25.0f); // just example
  6. }
  7.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

Details are here:
change_tab_icon-t2665.html
One can argue that it uses "private" information about TabWidget,
and, hence, can be changed "without notice"!
konic
Developer
Developer
 
Posts: 32
Joined: Mon Aug 24, 2009 3:16 pm

Postby sandis84 » Wed Oct 07, 2009 8:33 am

Hi, thx for the help. While your code did not work, from reading the code in your links I succeeded in solving my problem. Here is what worked for me:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. ArrayList<View> views = mTabHost.getTabWidget().getChildAt(i).getTouchables();
  3.  
  4. RelativeLayout relLayout = (RelativeLayout)views.get(0);
  5.  
  6. TextView tv = (TextView)relLayout.getChildAt(1);
  7.  
  8. tv.setTextSize(11);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
sandis84
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Fri Aug 07, 2009 3:54 pm

Postby konic » Wed Oct 07, 2009 12:00 pm

sandis84 wrote:Hi, thx for the help. While your code did not work,
from reading the code in your links I succeeded in solving my problem.
Here is what worked for me:

Don't see big difference with "my code", except I did not specified getTouchables(),
which is not that big deal unless you have some very fancy views.
Let Android Gurus correct me if I'm wrong :wink:
konic
Developer
Developer
 
Posts: 32
Joined: Mon Aug 24, 2009 3:16 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Majestic-12 [Bot], Yahoo [Bot] and 7 guests