0
我有一個在屏幕上移動的圖像視圖。所以,我已經設置了LayoutParams來做到這一點。但是,android堅持調整我的imageview。我怎樣才能防止這種行爲?圍繞屏幕移動視圖
public void move(int x, int y)
{
width = this.getWidth();
height = this.getHeight();
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WIDTH, HEIGHT);
int t = validateMin(calcTopPos(y));
int l = validateMin(calcLeftPos(x));
int r = validateMaxWidth(calcRightPos(x))-1;
int b = validateMaxHeight(calcBottomPos(y));
params.setMargins(l, t, r, b);
this.setLayoutParams(params);
requestLayout();
}
你能發佈layout.xml嗎? –
雖然你在它,重命名這些大寫的局部變量的寬度和高度;) –
@MartínMarconcini是正確的,你不應該使用大寫的變量不是最終/常量:) – codebringer