我已經找到了我一個解決方案。我從ListView(setSelector(new StateListDrawable()))中刪除所有選擇器狀態,並將一個OnTouchListener添加到ListView。
OnTouchListener觸發不同的方法來設置或刪除從視圖元素繪製的背景上的ColorFilter。 ColorFilter僅放置在塗漆(九塊或程序背景)區域上方,而不是放在缺口上方。
public class ClickAndReleaseListener implements View.OnTouchListener
{
/**
* Activity with integrated Adapter (from ListView) to do the triggered methods
*/
public IClickAndReleaseListener releaseListener;
/**
* Call from Activity (with the ListView) ex. listView.setOnTouchListener(new ClickAndReleaseListener(Activity.this))
* @param releaseListener => Activity with implemented Interface
*/
public ClickAndReleaseListener(IClickAndReleaseListener releaseListener)
{
this.releaseListener = releaseListener;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
//Aenderung der Visualisierung für das angeklickte Element.
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
//method find the triggered element and set a ColorFilter at the drawable background
//ex. visibleElement.getBackground().setColorFilter(ColorSpace.getHighlightColorFilter)
releaseListener.setColorFilter(event);
break;
case MotionEvent.ACTION_UP:
//method iterate to all elements and set a null ColorFilter at the drawable background
releaseListener.releaseColorFilter();
break;
}
return false;
}
}