手机有个列表,
是用一行行LinearLayout布局的
想实现当手指触摸一个LinearLayout时, 变背景色, 当UP时,恢复本来的颜色
当手指触摸移动到另行LinearLayout时, 本来的LinearLayout也恢复本来的背景色....
类似网页上的 MouseOver, MouseOut
这个效果怎么实现.................................
------解决方案--------------------
android的touch event是这样的,我觉得这样是合理的,如果你想拖个东西运动的话。
你这个可以结合move的距离和touch event一起配合实现这个效果。
一种是down,up改变颜色;
一种是move的时候判断移动到哪个item上了,改变颜色
------解决方案--------------------
你的意思是只想要Down和Up事件?如果是这样的话,当判断是Move的时候,
假设:View对象名称为v,Event名称为event
public boolean onTouch(View v, MotionEvent event)
{
if(event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_OUTSIDE)
{
MotionEvent event1 = MotionEvent.obtain(event);
event1.setAction(MotionEvent.ACTION_UP);
v.dispatchTouchEvent(event1);
return true;
}
//以下为你的Down或者Up事件代码
.......
return false;
}