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

解决在RelativeLayout等依赖view id的布局中findViewById的错误 #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

THEONE10211024
Copy link

原理:从findViewById的源码中可以看出,最终调用的是findViewTraversal,因此重写BadgeContainer的findViewTraversal的查找逻辑,即可完美解决依赖id的View布局导致的findViewById错误!

@@ -155,7 +155,7 @@ public Badge bindTarget(final View targetView) {
ViewGroup.LayoutParams targetParams = targetView.getLayoutParams();
targetContainer.removeView(targetView);
final BadgeContainer badgeContainer = new BadgeContainer(getContext());
if(targetContainer instanceof RelativeLayout){
if (targetContainer instanceof RelativeLayout) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是可以直接去掉 instanceof 的判断,把新增的 BadgeContainer id 直接变成原来 targetView 的 id

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

Successfully merging this pull request may close these issues.

2 participants