Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

手动点击对焦,首次对焦会出现偏差 #2675

Closed
ChawLoo opened this issue May 12, 2023 · 2 comments
Closed

手动点击对焦,首次对焦会出现偏差 #2675

ChawLoo opened this issue May 12, 2023 · 2 comments

Comments

@ChawLoo
Copy link

ChawLoo commented May 12, 2023

Current use version?

当前使用的版本是多少?

3.11.1

Will this problem occur in demo?

Demo能否复现这问题?

Describe the problem or provide an error log?

描述问题或提供错误log?

#FocusImageView
public void startFocus(Point point) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();
    params.topMargin = point.y - getMeasuredHeight() / 2;
    params.leftMargin = point.x - getMeasuredWidth() / 2;
    setLayoutParams(params);
    setVisibility(View.VISIBLE);
    setFocusResource(mFocusImg);
    startAnimation(mAnimation);
}
这部分代码存在问题,原因是首次点击,该视图并未绘制完成,getMeasuredHeight()和getMeasuredWidth()是获取不到宽高的,所以会产生偏移
@ChawLoo
Copy link
Author

ChawLoo commented May 12, 2023

我自己给他加了个post处理的

@ChawLoo
Copy link
Author

ChawLoo commented May 17, 2023

补充一个新的解决方案就是 把View设置成invisible 不要设置成gone 因为首次点击没有绘制 所以无法准确定位

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants