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

【BUG反馈】 #304

Closed
JersonSU opened this issue Apr 26, 2023 · 5 comments
Closed

【BUG反馈】 #304

JersonSU opened this issue Apr 26, 2023 · 5 comments
Labels
bug Something isn't working 已处理 已处理,等待结单 等待反馈 存疑或问题需要进一步确认

Comments

@JersonSU
Copy link

GuideDialog 不能围绕一个界面上的组件显示,实现舞台光的效果,我的代码:
xml:

<Button
    android:id="@+id/test_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:gravity="center"
    android:layout_margin="5dp"
    android:text="登录"
    android:textColor="@color/white"
    android:textSize="13dp"
    android:textStyle="bold"
    android:background="@color/theme"/>
fragment: public class WidgetFragment extends Fragment { private FragmentDashboardBinding binding; public View onCreateView(@nonnull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { WidgetViewModel widgetViewModel = new ViewModelProvider(this).get(WidgetViewModel.class); binding = FragmentDashboardBinding.inflate(inflater, container, false); View root = binding.getRoot(); **GuideDialog.show(binding.testBtn, R.drawable.ic_rem_up);** return root; } } 截图: ![image](https://user-images.githubusercontent.com/23331765/234489423-9372a50c-2ccc-41eb-a69c-9de2ca00edc1.png)
@JersonSU JersonSU added the bug Something isn't working label Apr 26, 2023
@JersonSU
Copy link
Author

activity:
public class WidgetFragment extends Fragment {

private FragmentDashboardBinding binding;

public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    WidgetViewModel widgetViewModel = new ViewModelProvider(this).get(WidgetViewModel.class);

    binding = FragmentDashboardBinding.inflate(inflater, container, false);
    View root = binding.getRoot();

    GuideDialog.show(binding.testBtn, R.drawable.ic_rem_up);

    return root;
}

@Override
public void onDestroyView() {
    super.onDestroyView();
    binding = null;
}

}

@JersonSU
Copy link
Author

截图:
QQ截图20230426143535

@kongzue
Copy link
Owner

kongzue commented Apr 26, 2023

看样子是GuideDialog在启动时未能正确获得Button的位置。请尝试在Button完成渲染后再启动,例如:

button.post(new Runnable{
  @Override
  public void run() {
      GuideDialog.show(...);
  }
})

GuideDialog中是通过 view.getLocationOnScreen(...) 方法获取绑定的按钮位置的,在 activity 刚启动时可能存在 view 没有得到正确的渲染位置坐标是 0,0 的问题,这个问题系系统问题,请适当延迟后执行。
另外请参阅Demo,GuideDialog本身是没有任何问题的。
image

@kongzue kongzue added the 已处理 已处理,等待结单 label Apr 26, 2023
@JersonSU
Copy link
Author

非常棒,使用button.post(new Runnable{});可以了。非常感谢!

@stale
Copy link

stale bot commented Jun 28, 2023

长时间未收到回复暂时关闭了此问题,若有疑问请继续回复。此消息来自于自动化 Issues 处理 Bot,若问题严重或紧急你也可以通过反馈群联系到我:590498789

@stale stale bot added the 等待反馈 存疑或问题需要进一步确认 label Jun 28, 2023
@kongzue kongzue closed this as completed Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 已处理 已处理,等待结单 等待反馈 存疑或问题需要进一步确认
Projects
None yet
Development

No branches or pull requests

2 participants