2010-12-16 8 views
1

タブのUIを作成しようとしていますが、tabHostsに画像を配置したくないため、setIndicator(CharSequenceラベル、Drawableアイコン)を使用する代わりにsetIndicator(CharSequence label)を使用します。 tabHostは画像なしで作成されますが、高さが小さく、CharSeququenceだけを含んでいますが、画像付きの通常のtabHostと同じ高さです。画像が通常存在し、テキストがその空きスペースの下にある空きスペースが上部にあります。とにかく、イメージのために予約されている空き領域を削除するか、または2つを反転させて、テキストが上になるようにします。その後、例えば15dpのlayout_heightを設定することができます。メインレイアウトの.xmlコードは、あなたが背景として@null設定し、空き領域を除去するために、負のマージンができAndroid:TabHost.TabSpec setIndicator(CharSequence label)

<?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="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> 

答えて

2

です。背景が助けにはならなかった、と私は唯一残っていないTabWidgetの上部に空きスペースを除去するために必要と権利が、あなたのアドバイスのおかげで、私はちょうどアンドロイドを設定することができます考え出したとして@null設定

<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" /> 
+2

:layout_marginTop = " - 25dp"それは私の問題を解決する(私はタブを変更するときに苦労しないようにいくつかのスペースを一番上に残すことにした) アドバイスをいただきありがとうございます! – Peter