Home » Java » java – Get a point that's 25% of the screen size in Android-Exceptionshub

java – Get a point that's 25% of the screen size in Android-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I use an android Studio Library that requires me to use a pointF when using a position. For the Y value I just use max screen size. For the x value I would like it to be 25% of the screen size, how do I do this?
This is what I have right now:

Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    new ShowCaseStepDisplayer.Builder(getActivity())
    .addStep(new ShowCaseStep(new Position(new PointF(510, size.y)), "Based upon the information you've provided, we've selected certain articles for you"))
How to&Answers:

you can simply calculate value, like getResources().getDisplayMetrics().widthPixels * 0.25