Android View 拖动&插入 研究
2010-07-01 14:10:00 来源:WEB开发网核心提示:ImageView iv = (ImageView)lLayout.getChildAt(i);ImageView iv2 = (ImageView)lLayout.getChildAt(i+1);if(iv.getTop()< v.getTop() && iv2.getTop() > v.getTop()
ImageView iv = (ImageView)lLayout.getChildAt(i);
ImageView iv2 = (ImageView)lLayout.getChildAt(i+1);
if(iv.getTop()< v.getTop() && iv2.getTop() > v.getTop()){
//refer delta of point1 & point2
if(point1 < point2){//drag to bottom
return i+1;
}
else {//drag to up
return i+1;
}
}
}
//otherwise return last location
return lLayout.getChildCount()-1;
}
public int getLocation(View v){
for(int i=0;i
ImageView iv = (ImageView)lLayout.getChildAt(i);
ImageView iv2 = (ImageView)lLayout.getChildAt(i+1);
if(iv.getTop()< v.getTop() && iv2.getTop() > v.getTop()){
//refer delta of point1 & point2
if(point1 < point2){//drag to bottom
return i+1;
}
else {//drag to up
return i+1;
}
}
}
//otherwise return last location
return lLayout.getChildCount()-1;
}
5. emulator 运行截图:
- 拖拉前:
- 拖拉后:
更多精彩
赞助商链接