Display display;
display = ((WindowManager)
context.getSystemService(context.WINDOW_SERVICE)).getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
// cell size of a widget in portrait mode
int xCellSize = 80;
int yCellSize = 100;
if (metrics.widthPixels > metrics.heightPixels)
{
// this means we're in landscape mode, so the cell sizes are adjusted
xCellSize = 106;
yCellSize = 74;
}
int xWidgetSize = 4;
int yWidgetSize = 1;
Log.v("debug",
String.format("your %d x %d appwidget is %d x %d physical pixels.",
xWidgetSize, yWidgetSize,
(int)(xCellSize * xWidgetSize * metrics.density),
(int)(yCellSize * yWidgetSize * metrics.density)));각 셀의 실제 코드를 구하는 예제
'Programming > Android' 카테고리의 다른 글
| INSTALL_FAILED_CONFLICTING_PROVIDER (0) | 2015.06.30 |
|---|---|
| Android Studio: Failed to complete Gradle execution (0) | 2014.08.22 |
| 안드로이드 매니페스트에서 버전 정보 가져오기 (0) | 2014.08.06 |
| Android Studio Build (0) | 2014.07.31 |