0

this is my tab it has extra some spaces i need to remove them. this is my code

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:padding="0dip"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
    </LinearLayout>
</TabHost>

mainactivity class:

public class MainActivity extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TabHost tabHost = getTabHost();

        // Tab for Photos
        TabSpec photospec = tabHost.newTabSpec("Photos");
        // setting Title and Icon for the Tab
        photospec.setIndicator("Photos");
       // photospec.setText("da");
        Intent photosIntent = new Intent(this, SplashActivity.class);
        photospec.setContent(photosIntent);

       // Tab for Videos
        TabSpec videospec = tabHost.newTabSpec("Videos");
        videospec.setIndicator("Videos");
        Intent videosIntent = new Intent(this, MainActivity.class);
        videospec.setContent(videosIntent);

        // Adding all TabSpec to TabHost
        tabHost.addTab(photospec); // Adding photos tab

        tabHost.addTab(videospec); // Adding videos tab
    }
}

i tried to change the size of the tab in layout like this

   <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="23dp"
            android:padding="0dip" />

if i do this text will be hidden. enter image description here

when i reduce the height it becomes like this and text also hides enter image description here

DolDurma
  • 15,753
  • 51
  • 198
  • 377
Thamaraiselvam
  • 6,961
  • 8
  • 45
  • 71

1 Answers1

0

Try this code:

for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
     tabHost.getTabWidget().getChildAt(i).getLayoutParams().height /=2; 
}

PS: I copy/paste it from here

Community
  • 1
  • 1
Rami
  • 7,879
  • 12
  • 36
  • 66