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

set proper location & size of view to be highlight #28

Open
rtinku opened this issue Feb 16, 2018 · 0 comments
Open

set proper location & size of view to be highlight #28

rtinku opened this issue Feb 16, 2018 · 0 comments

Comments

@rtinku
Copy link

rtinku commented Feb 16, 2018

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();
    }
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

1 participant