Skip to content

Instantly share code, notes, and snippets.

@tikitikipoo
Created January 5, 2012 01:14
Show Gist options
  • Save tikitikipoo/1563181 to your computer and use it in GitHub Desktop.
Save tikitikipoo/1563181 to your computer and use it in GitHub Desktop.
Androidにおける画面のサイズを取得
import android.content.Context;
import android.view.Display;
import android.view.WindowManager;
public static class ScreenSize {
public static int getScreenWidth(Context context) {
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
return display.getWidth();
}
public static int getScreenHeight(Context context) {
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
return display.getHeight();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment