2011-08-11 13 views
0

私はこの質問を以前に聞いたことがありますが、今までの正確な問題は何か分かりませんでした。私の問題は、私がカスタムのスピナー/アダプターを作ったことと、スピナーの行の適切な間隔を確保するためにパディングを5dipに設定したことです。問題は、より多くのパディングを補うためにスピナーを大きくするために必要なパディングを追加するときです。選択したアイテムのパディングを無視できる方法はありますか?したがって、スピナーが折りたたまれている場合は、パディングは無視され、展開されるとパディングが使用されます。Android:パディングを無視する

スピナーの行のためのxml:

<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <TableRow 
    android:id="@+id/tableRow1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="5dip"> 

    <ImageView 
     android:layout_width="32sp" 
     android:src="@drawable/icon" 
     android:id="@+id/spinnerimage" 
     android:layout_height="32sp" /> 

    <TextView 
     android:textSize="22sp" 
     android:textStyle="bold" 
     android:textColor="#000" 
     android:layout_width="fill_parent" 
     android:id="@+id/category" 
     android:layout_height="wrap_content" 
     android:paddingLeft="5sp" /> 

    </TableRow> 

</TableLayout> 

とスピナー:

 <Spinner 
     android:id="@+id/catspinner" 
     android:layout_marginLeft="25dip" 
     android:layout_marginRight="25dip" 
     android:layout_width="fill_parent" 
     android:layout_centerHorizontal="true" 
     android:layout_height="wrap_content" 
     android:prompt="@string/prompt" 
     android:background="@drawable/yellow_btn" 
     android:layout_centerVertical="true" 
     android:drawSelectorOnTop="true" /> 

答えて

1

デフォルトのドローアブルを使用している場合は、パディングあなたが「方法を変更することはできませんもう一度お願いします。

デフォルトドロアブルの動作を無効にするには、独自のninepatchドロワブルを作成してアプリに含める必要があります。

+0

私はこれを回避することを望んでいましたが、あなたは正しいです。 – Nick

+0

私は同じことをやろうとしました。がんばろう :) – Codeman

関連する問題