Answer the question
In order to leave comments, you need to log in
Determine coordinates of objects on screen, Android studio (java)?
Good afternoon. I need to determine the size of the display and, depending on its size, set the location of several buttons.
When you click on one of the buttons, you need to place a few more buttons so that the new buttons in no case intersect with other buttons and go beyond the screen.
I do not ask you to write code for me, but I will be grateful for the description and examples.
Answer the question
In order to leave comments, you need to log in
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics outMetrics = new DisplayMetrics ();
display.getMetrics(outMetrics);
float density = getResources().getDisplayMetrics().density;
float dpHeight = outMetrics.heightPixels / density;
float dpWidth = outMetrics.widthPixels / density;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question