Answers for "how to get view default width and height in android"

1

android get screen width and height

DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
float dpHeight = displayMetrics.heightPixels / displayMetrics.density;
float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
Log.d("MyHeight", dpHeight+"");
Log.d("MyWidth", dpWidth+"");
Posted by: Guest on May-31-2021
0

set view size android

someView.setLayoutParams(new LayoutParams(width, height));
Posted by: Guest on June-16-2020

Code answers related to "how to get view default width and height in android"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language