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

2.2.3下 相对位置无效 #313

Closed
macleo opened this issue Jul 4, 2020 · 8 comments
Closed

2.2.3下 相对位置无效 #313

macleo opened this issue Jul 4, 2020 · 8 comments
Labels
bug pending release 待发布正式版

Comments

@macleo
Copy link

macleo commented Jul 4, 2020

提issue前请去WIKI#常见问题找找相关问题,避免重复提问

提issue前请务必参考以下格式填写,否则该问题可能会【被忽略】

  • 系统版本(必须):android 7.0
  • 库版本(必须):2.2.3
  • 问题描述/重现步骤(必须):2.2.3下 相对位置无效 ,2.2.1 ok
  • 问题代码/截图(可选):
    //为 layout中的一个ImageView
    AppCompatImageView iv_supervise =(AppCompatImageView) findViewById(R.id.iv_supervise);
    demoPop = new DemoPop(this);
    demoPop.setPopupGravity(BasePopupWindow.GravityMode.RELATIVE_TO_ANCHOR, Gravity.BOTTOM);
    demoPop.showPopupWindow(iv_supervise);
  • 报错信息(可选):
    没有

@razerdp
Copy link
Owner

razerdp commented Jul 4, 2020

是否继承的BaseLazyPopup

@macleo
Copy link
Author

macleo commented Jul 4, 2020

1593878677870

是否继承的BaseLazyPopup

BasePopupWindow


public class DemoPop extends BasePopupWindow {
private ImageView mIvArrow;
public DemoPop(Context context) {
super(context);
}

// 必须实现,这里返回您的contentView
// 为了让库更加准确的做出适配,强烈建议使用createPopupById()进行inflate
@Override
public View onCreateContentView() {
    return createPopupById(R.layout.popup_tip);
}

@Override
protected Animation onCreateShowAnimation() {
    AnimationSet set=new AnimationSet(false);
    Animation shakeAnima=new RotateAnimation(0,15,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    shakeAnima.setInterpolator(new CycleInterpolator(5));
    shakeAnima.setDuration(400);
    set.addAnimation(getDefaultAlphaAnimation());
    set.addAnimation(shakeAnima);
    return set;
}

}

.showPopupWindow时位置会跑到Activity的最左上角,同样的东西,换成2.2.1,一切就OK,先用2.2.1了。谢谢。
Uploading 1593878677870.jpg…

@razerdp
Copy link
Owner

razerdp commented Jul 4, 2020

2.2.3与2.2.1貌似在layout这一块没怎么改动过。而且每次发布前都会经过demo内所有内容的测试的说。。。

能提供复现demo吗

@macleo
Copy link
Author

macleo commented Jul 4, 2020

2.2.3与2.2.1貌似在layout这一块没怎么改动过。而且每次发布前都会经过demo内所有内容的测试的说。。。

能提供复现demo吗

我发你的邮箱么?可以的

@razerdp
Copy link
Owner

razerdp commented Jul 5, 2020

2.2.3与2.2.1貌似在layout这一块没怎么改动过。而且每次发布前都会经过demo内所有内容的测试的说。。。
能提供复现demo吗

我发你的邮箱么?可以的

ok,或者你直接拖进来评论这里,应可以上传的

@macleo
Copy link
Author

macleo commented Jul 5, 2020

demo

2.2.3与2.2.1貌似在layout这一块没怎么改动过。而且每次发布前都会经过demo内所有内容的测试的说。。。
能提供复现demo吗

我发你的邮箱么?可以的

ok,或者你直接拖进来评论这里,应可以上传的
发到你gmail.com邮箱了,
步骤 1. 2.2.1 跑一遍
再2.2.3 跑一遍,就能复现。辛苦了。
implementation 'com.github.razerdp:BasePopup:2.2.1'

@razerdp razerdp added bug pending release 待发布正式版 labels Jul 5, 2020
razerdp added a commit that referenced this issue Jul 5, 2020
@razerdp
Copy link
Owner

razerdp commented Jul 5, 2020

问题已确认。

请更新到 candy 2.2.4.0705 尝试,正式版本暂时还没发布。

【问题产生原因】:
在onCreate时,view是并没有完成测量过程的,此时弹窗并关联anchorView时会导致BasePopup无法弹窗并等待DecorView(即Activity)AttachToWindow。

在attach之后,此时可以弹窗(因为有windowToken),但是锚点view依然没有进行测量,因此无法获取该view位置,所以在左上角弹出(位置:0,0)

【问题解决方案】:
在AttachToWindow后,重新弹窗的时候放到post后,因为post的消息是在完成一系列操作后才会去处理的(view#attachToWindow),能保证在测量过后弹出。

【问题解决版本】:

candy 2.2.4.0705

【回归记录】:

ezgif-4-93c2a793592a

@razerdp
Copy link
Owner

razerdp commented Jul 19, 2020

release 2.2.4 已经发布,本issue修复已被包含。
具体信息请到README或文档查阅新版本更新内容

@razerdp razerdp closed this as completed Jul 19, 2020
razerdp added a commit that referenced this issue Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pending release 待发布正式版
Projects
None yet
Development

No branches or pull requests

2 participants