Skip to content

Instantly share code, notes, and snippets.

View ec84b4's full-sized avatar

Khaled Bakhtiari ec84b4

View GitHub Profile
@ec84b4
ec84b4 / screenSize
Last active January 7, 2018 20:17
android screen size
public void setScreenSize(Context context) {
int x, y, orientation = context.getResources().getConfiguration().orientation;
WindowManager wm = ((WindowManager)
context.getSystemService(Context.WINDOW_SERVICE));
Display display = wm.getDefaultDisplay();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
Point screenSize = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(screenSize);
x = screenSize.x;