This subject is discussed in the Android Training:
http://developer.android.com/training/multiscreen/screensizes.html#TaskUseSWQuali
If you read the entire topic, they explain how to set a boolean value in a specific value file (as res/values-sw600dp/):
<resources>
<bool name="isTablet">true</bool>
</resources>
Because the sw600dp qualifier is only valid for platforms above android 3.2. If you want to make sure this technique works on all platforms (before 3.2), create the same file in res/values-xlarge folder:
<resources>
<bool name="isTablet">true</bool>
</resources>
Then, in the "standard" value file (as res/values/), you set the boolean to false:
<resources>
<bool name="isTablet">false</bool>
</resources>
Then in you activity, you can get this value and check if you are running in a tablet size device:
boolean tabletSize = getResources().getBoolean(R.bool.isTablet);
if (tabletSize) {
// do something
} else {
// do something else
}
'Android > 개발팁' 카테고리의 다른 글
[Android] 핸드폰 고유값을 서버에 전송할 수 있을까? (0) | 2014.11.27 |
---|---|
Android 에뮬레이터 웹브라이저에서 localhost 입력 (0) | 2013.12.16 |
Gradient buttons (0) | 2013.08.22 |
Thread Hanlder 간단하게 쓰기 (0) | 2013.07.24 |
★ setBackground vs setBackgroundDrawable / AlertDialog (0) | 2013.07.12 |