Created
January 5, 2012 01:14
-
-
Save tikitikipoo/1563181 to your computer and use it in GitHub Desktop.
Androidにおける画面のサイズを取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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