Tab Host height in android

    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {

            Log.v("","tabhost...");
            Log.v("","tabHost.getTabWidget().getChildAt(i).getLayoutParams() " +tabHost.getTabWidget().getChildAt(i));
            RelativeLayout relativeLayout = (RelativeLayout)tabHost.getTabWidget().getChildAt(i);
            relativeLayout.getChildCount();
            Log.v("","count  "+relativeLayout.getChildCount()+"   relativeLayout.getChildAt(i) "+relativeLayout.getChildAt(i));
            TextView tabhostText = (TextView) relativeLayout.getChildAt(1);

            tabhostText.setTextSize(20.0f);
            tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 30;

        }

In the above code everything is working fine i.e., i am able to see the Text on the tab. But i am not able to see the text in the Device. only some part of the text is visible. please could any body find some solution.

Thanks in advance..

Answers


I know your question is 10 months old now, but the reason only part of the text is visible is because you set the height to just 30. The default on your phone is probably 96 pixels (or maybe 64 if your phone has lower res).

If you want to make your code more universal, you can get the height of the tabs first, then set the height of each tab to a percentage of the original height. In the example below I set the height of the tabs to 80% of the original height.:

    double height = tabHost.getTabWidget().getChildAt(0).getLayoutParams().height;

    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {

                RelativeLayout relativeLayout = (RelativeLayout)tabHost.getTabWidget().getChildAt(i);
                TextView tabhostText = (TextView) relativeLayout.getChildAt(1);

                tabhostText.setTextSize(20.0f);
                tabHost.getTabWidget().getChildAt(i).getLayoutParams().height =  (int) (0.8 * height);

            }

p.s. You may want to word your question better next time. I think I understand what you're asking, but only because I'm working on the exact same thing. Try wording your question in normal question form (e.g. ending with a question mark).


I found solution.

View v = getLayoutInflater().inflate(R.layout.tab_header, null);
tabSpec.setIndicator(v);

Just use custom layout for tabs.


Need Your Help

JavaScript : How to detect if a node has been removed?

javascript jquery memory

I think the best way to describe my question is to create some image objects in such a matter:

How to view a public Google Calendar via an Android Application

java android view calendar

I must've gone through ever Stack Overflow question based on the Google Calendar so far with no luck what so ever. I've been trying this for hours now and got little to no results at all.