1

さて、タブにカスタムルックを追加するための以下のコードで(うまく機能します)、描画可能な画像の周りに境界線(パディングまたはある種のトリミング)が表示されます。これをどこでどのように修正しますか?

アクティビティ:

 TabHost mTabHost = getTabHost();
 Drawable mySelector = getResources().getDrawable(R.drawable.tabselector);
 mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1" , mySelector).setContent(R.id.textview1));

部分的なタブセレクタ XML:

<selector
    android:id="@+id/myselector"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Non focused states -->
    <item
        android:state_focused="false"
        android:state_selected="false"
        android:state_pressed="false"
        android:drawable="@drawable/darklogo"/>
    <item
        android:state_focused="false"
        android:state_selected="true"
        android:state_pressed="false"
        android:drawable="@drawable/lightlogo" />

メイン XML:

<TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:padding="0px"
            android:layout_marginBottom ="-4px"
            android:clipToPadding="false" />

スクリーンショットを投稿することはできません...

4

1 に答える 1

0

私があなたを正しく理解していれば、実際には非常に簡単です。

要素にvariablePadding属性を設定するだけtrueです。selector

これがどのように見えるかです。

<selector
android:id="@+id/myselector"
android:variablePadding="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item
    android:state_focused="false"
    android:state_selected="false"
    android:state_pressed="false"
    android:drawable="@drawable/darklogo"/>
<item
    android:state_focused="false"
    android:state_selected="true"
    android:state_pressed="false"
    android:drawable="@drawable/lightlogo" />

3 行目に注意してください。

于 2010-09-08T18:07:17.867 に答える