gpt4 book ai didi

java - 设置RelativeLayout Param高度时ImageView的尺寸会缩小

转载 作者:行者123 更新时间:2023-12-01 10:38:30 26 4
gpt4 key购买 nike

我有一项 Activity ,其作用类似于底表。我已将其设置为用户可以用手指拖动它,它会相应地移动。一切正常,除非拖动底部表单时,最接近底部的图标会被调整大小,而不是直接从屏幕上掉下来。这会产生奇怪且不需要的效果。

这是正在发生的事情的图片:

Problem

调整大小的方法如下:

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;
}
}
});
}

最佳答案

试试这个

  imageView.setScaleType(ImageView.ScaleType.FIT_XY);

关于java - 设置RelativeLayout Param高度时ImageView的尺寸会缩小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34548584/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com