Android 拖动View View跟随手指一动


/**
* 拖动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);
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM