florent37 / florent37/TutoShowcase

set proper location & size of view to be highlight

Open
#28 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
499
Forks
85
PR merge metrics
No merged PRs in 30d

Description

i face some issue to highlight view . when i use this some device show it perfect. some device not show perfectly . so i make some adjustment to achieve this .

here i show code which i make adjustment.

private void addCircleOnView(float additionalRadiusRatio) {
Rect rect = new Rect();
int[] locations = new int[2];
view.getGlobalVisibleRect(rect);
view.getLocationOnScreen(locations);

Log.i(TAG, "addCircleOnView: rect values");
Log.i(TAG, "addCircleOnView:left " + rect.left);
Log.i(TAG, "addCircleOnView:top " + rect.top);
Log.i(TAG, "addCircleOnView:right " + rect.right);
Log.i(TAG, "addCircleOnView:bottom " + rect.bottom);

Log.i(TAG, "addCircleOnView: using view's method");

Log.i(TAG, "addCircleOnView:X " + view.getX());
Log.i(TAG, "addCircleOnView:Y " + view.getY());

Log.i(TAG, "addCircleOnView:get top " + view.getTop());
Log.i(TAG, "addCircleOnView: get left " + view.getLeft());
Log.i(TAG, "addCircleOnView: get right " + view.getRight());
Log.i(TAG, "addCircleOnView:get bottom " + view.getBottom());

Log.i(TAG, "addCircleOnView: loction on screen");
Log.i(TAG, "addCircleOnView:location X " + locations[0]);
Log.i(TAG, "addCircleOnView: location Y " + locations[1]);

view.getLocationOnScreen(locations);
int cx;
cx = (int) (rect.left + rect.top - view.getY());
int cy = rect.top;
// int cy = locations[1];
int radius = (int) (Math.max(rect.width(), rect.height()) / 2f * additionalRadiusRatio);
Circle circle = new Circle(cx, cy, radius);
circle.setDisplayBorder(settings.withBorder);

tutoShowcase.tutoView.addCircle(circle);

addClickableView(rect, settings.onClickListener, additionalRadiusRatio);

tutoShowcase.tutoView.postInvalidate();
}

private void addRoundRectOnView(float additionalRadiusRatio) {
Rect rect = new Rect();
int locations[] = new int[2];
view.getLocationOnScreen(locations);
view.getGlobalVisibleRect(rect);
int padding;

Log.i(TAG, "addRectOnView: rect values");
Log.i(TAG, "addRectOnView:left " + rect.left);
Log.i(TAG, "addRectOnView:top " + rect.top);
Log.i(TAG, "addRectOnView:right " + rect.right);
Log.i(TAG, "addRectOnView:bottom " + rect.bottom);
Log.i(TAG, "addRectOnView:width " + rect.width());
Log.i(TAG, "addRectOnView:height " + rect.height());

Log.i(TAG, "addRectOnView: using view's method");

Log.i(TAG, "addRectOnView:X " + view.getX());
Log.i(TAG, "addRectOnView:Y " + view.getY());

Log.i(TAG, "addRectOnView:get top " + view.getTop());
Log.i(TAG, "addRectOnView: get left " + view.getLeft());
Log.i(TAG, "addRectOnView: get right " + view.getRight());
Log.i(TAG, "addRectOnView:get bottom " + view.getBottom());
Log.i(TAG, "addRectOnView:width " + view.getWidth());
Log.i(TAG, "addRectOnView:height " + view.getHeight());

Log.i(TAG, "addRectOnView: loction on screen");
Log.i(TAG, "addRectOnView:location X " + locations[0]);
Log.i(TAG, "addRectOnView: location Y " + locations[1]);

int x, y, width, height;

if (Build.VERSION.SDK_INT < 20) {
x = view.getLeft() - view.getLeft() / 4;
y = locations[1] - 40;
width = view.getWidth() + view.getLeft() / 2;
height = rect.height();
} else {
x = view.getLeft() - view.getLeft() / 4;
y = rect.top;
width = view.getWidth() + view.getLeft() / 2;
height = rect.height();
}
RoundRect roundRect = new RoundRect(x, y, width, height);
roundRect.setDisplayBorder(settings.withBorder);
tutoShowcase.tutoView.addRoundRect(roundRect);
addClickableView(rect, settings.onClickListener, additionalRadiusRatio);
tutoShowcase.tutoView.postInvalidate();
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.