[英]imageview resizing while dragging a image in layout in android
我正在創建一個我需要在其中拖動imageview的android應用程序。 我嘗試使用布局參數及其移動正常,但是當圖像在設備的右下角附近移動時,imageview會重新調整大小。 我不知道為什么會這樣。 我的代碼低於我嘗試的代碼。
if (me.getAction() == MotionEvent.ACTION_MOVE) {
drag=true;
if(drag){
int x=(int) (me.getRawX());
int y=(int) (me.getRawY());
innerlayout.setLayoutParams(new RelativeLayout.LayoutParams(innerlayout.getLayoutParams().width, innerlayout.getLayoutParams().height));
LayoutParams params = (LayoutParams) innerlayout.getLayoutParams();
params.leftMargin = x-25;
params.topMargin = y-75;
innerlayout.setLayoutParams(params);
}
}
else if(me.getAction() == MotionEvent.ACTION_UP)
{
drag=false;
}
return true;
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.