これは私のカスタムセレクターです(StateListDrawable)
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/common_cell_background" />
<item
android:state_pressed="true"
android:drawable="@drawable/common_cell_background_highlight" />
<item
android:state_focused="true"
android:drawable="@drawable/common_cell_background_highlight" />
<item
android:state_selected="true"
android:drawable="@drawable/common_cell_background_highlight" />
</selector>
common_cell_backgroundとcommon_cell_background_highlightはどちらもXMLです。以下のコード:
common_cell_background.xml
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/common_cell_background_bitmap"
android:tileMode="repeat"
android:dither="true">
</bitmap>
common_cell_background_highlight.xml
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/common_cell_background_bitmap_highlight"
android:tileMode="repeat"
android:dither="true">
</bitmap>
ビットマップもまったく同じです。ハイライトは少し軽く、他に違いはありません。両方のビットマップはPNGファイルです。
今私は設定しました
convertView.setBackgroundResource(R.drawable.list_item_background);
そしてここに問題があります。私のcommon_cell_backgroundは繰り返されず、引き伸ばされています。しかし、リストのセルにタッチすると、背景がcommon_cell_background_highlightに変わり、何を推測するのでしょうか。すべてが順調です、それはあるべきように繰り返されます。どこに問題があるのか、ハイライトが繰り返されるのに背景が繰り返されないのはなぜかわかりません。何かご意見は?