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

getYForTooTip does not handle CENTER_VERTICAL gravity #59

Open
peterosterlund2 opened this issue Jan 11, 2016 · 1 comment
Open

getYForTooTip does not handle CENTER_VERTICAL gravity #59

peterosterlund2 opened this issue Jan 11, 2016 · 1 comment

Comments

@peterosterlund2
Copy link

I think the getYForTooTip method should look something like this:

private int getYForTooTip(int gravity, int toolTipMeasuredHeight, int targetViewY, float adjustment){
    int y;
    if ((gravity & Gravity.TOP) == Gravity.TOP) {

        if (((gravity & Gravity.LEFT) == Gravity.LEFT) || ((gravity & Gravity.RIGHT) == Gravity.RIGHT)) {
            y =  targetViewY - toolTipMeasuredHeight + (int)adjustment;
        } else {
            y =  targetViewY - toolTipMeasuredHeight - (int)adjustment;
        }
    } else if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
        if (((gravity & Gravity.LEFT) == Gravity.LEFT) || ((gravity & Gravity.RIGHT) == Gravity.RIGHT)) {
            y =  targetViewY + mHighlightedView.getHeight() - (int) adjustment;
        } else {
            y =  targetViewY + mHighlightedView.getHeight() + (int) adjustment;
        }
    } else { // this is center
        if (((gravity & Gravity.LEFT) == Gravity.LEFT) || ((gravity & Gravity.RIGHT) == Gravity.RIGHT)) {
            y =  targetViewY + mHighlightedView.getHeight() / 2 - (int) adjustment;
        } else {
            y =  targetViewY + mHighlightedView.getHeight() / 2 + (int) adjustment;
        }
    }
    return y;
}
@worker8
Copy link
Owner

worker8 commented Jan 12, 2016

Hi @peterosterlund2
Your code actually looks good, that should fix Gravity.BOTTOM, can you make a pull request?

I will then test and merge it.

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

2 participants