/**
* 拖动View 配合onTouchListener使用
* 设置View的布局属性,使得view随着手指移动 注意:view所在的布局必须使用RelativeLayout 而且不得设置居中等样式
*
* @param view
* @param rawY
*/
private void moveViewWithFinger(View view, float rawY ,int statusBar) {
if (rawY> view.getHeight()){
rawY = view.getHeight() + statusBar;
}
int left = 0;
int top = (int) rawY - mProfile.getHeight();
int width = view.getWidth();
int height = top + view.getHeight();
view.layout(left, top, width, height);
}
转载于:https://www.cnblogs.com/teddy-yan/p/6133621.html