0
我有一個活動就像底部工作表一樣。我已經設置好了,所以用戶可以用手指拖動它,它會相應地移動。所有的效果都很好,除非當底部圖被拖動時,無論哪個圖標離底部最近都會被調整大小,而不是從屏幕上掉下來。這會產生一種奇怪的和不希望的效果。設置RelativeLayout時,ImageViews會縮小尺寸參數高度
這裏是正在發生的一個畫面:
下面是調整的方法:
public void setAdjustableTouchListener() {
full.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
mDragStartY = event.getY();
mDraggingStarted = SystemClock.elapsedRealtime();
mPointerOffset = event.getRawY() + main.getMeasuredHeight();
return true;
case MotionEvent.ACTION_UP:
if (mDragStartY < (event.getY() + TAP_DRIFT_TOLERANCE) && mDragStartY > (event.getY() - TAP_DRIFT_TOLERANCE)
&& ((SystemClock.elapsedRealtime() - mDraggingStarted) < SINGLE_TAP_MAX_TIME)) {
result = "Dismissed";
finish();
} else {
if (main.getMeasuredHeight() > (viewConversion + heightDifference)) {
ResizeAnimation a = new ResizeAnimation(main);
a.setDuration(500);
a.setParams(main.getMeasuredHeight(), extendedViewHeight);
main.startAnimation(a);
} else if (main.getMeasuredHeight() < (viewConversion + heightDifference)
&& main.getMeasuredHeight() > viewConversion) {
ResizeAnimation a = new ResizeAnimation(main);
a.setDuration(500);
a.setParams(main.getMeasuredHeight(), viewConversion);
main.startAnimation(a);
} else if (main.getMeasuredHeight() < viewConversion && main.getMeasuredHeight() > (viewConversion/2)) {
ResizeAnimation a = new ResizeAnimation(main);
a.setDuration(500);
a.setParams(main.getMeasuredHeight(), viewConversion);
main.startAnimation(a);
} else {
result = "Dismissed";
finish();
}
}
return true;
case MotionEvent.ACTION_MOVE:
if (mPointerOffset - event.getRawY() < extendedViewHeight)
setPrimaryContentHeight((int) (mPointerOffset - event.getRawY()));
return true;
default:
return true;
}
}
});
}
這改變了它,但圖標隱藏時仍然有一個奇怪的效果。我會嘗試解決不同的ScaleType選項,看看我能否找到一個可以工作的圖標 –
很高興幫忙 –
好的,MATRIX工作正常,但它使所有的圖像顯得很奇怪。我將與FIT_END一起使用,因爲它具有很酷的效果,並且至少可以使其發揮作用。謝謝! –