Android: TabHost.TabSpec setIndicator (CharSequence label)
I am trying to create a tab UI, but I don't want to put any images on the tabHosts, so instead of using setIndicator(CharSequence label, Drawable icon) I decided to use setIndicator (CharSequence label). The tabHost is then created without an image but insead of being smaller in height and just containing the CharSeququence, it is of the same height as a regular tabHost with an image. There is a free space on top where the image is usually situated and the text is below that empty space. Is there anyway to remove the free space reserved for the image, or to flip the two, so that the text is on top, after which I can just set a layout_height of 15dp for example. The .xml code for the main layout is
<?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开发者_如何学Go:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
You can set @null as a background, and negative margin to remove free space.
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginLeft="-2dp"
android:layout_marginRight="-2dp" />
精彩评论