簡體   English   中英

在RelativeLayout內部移動ImageView

[英]Move ImageView around inside RelativeLayout

我需要在RelativeLayout內部移動ImageView(或其他任何東西)。 有沒有人知道這樣做的正確方法?

Menseure ImageViewlayout_heightlayout_width設置為fill_parent 然后做:

要移動視圖,請使用Matrix 這非常方便。

Matrix matrix = new Matrix();

matrix.reset();

matrix.postTranslate(x, y);

imageview.setScaleType(ScaleType.MATRIX);
imageview.setImageMatrix(matrix);

我找到了這個:

imageview.layout(l,t,r,b);

mImageView.scrollBy(xOffset,yOffset);

這很容易。 你可以實現你想要的任何控件的onTouchListener事件,並設置它的x,y位置,比如make一個新的LayoutParams設置它的x,y並分配給view.setLayoutParam(layoutParams); 它將拖動視圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM