Get the screen size in Android
2010-03-19 21:30
363 查看
Android screen size is different for different phone models.
There are some screen resolutions already defined in Android.
They are:
QVGA (240×320, low density, small screen)
WQVGA (240×400, low density, normal screen)
FWQVGA (240×432, low density, normal screen)
HVGA (320×480, medium density, normal screen)
WVGA800 (480×800, high density, normal screen)
WVGA854 (480×854 high density, normal screen)
Now let’s see how to get the screen size,
view source
print?
Here, ht will return the height & wt will return the width.
There are some screen resolutions already defined in Android.
They are:
QVGA (240×320, low density, small screen)
WQVGA (240×400, low density, normal screen)
FWQVGA (240×432, low density, normal screen)
HVGA (320×480, medium density, normal screen)
WVGA800 (480×800, high density, normal screen)
WVGA854 (480×854 high density, normal screen)
Now let’s see how to get the screen size,
view source
print?
01 | @Override |
02 | public void onCreate(Bundle savedInstanceState) { |
03 | super .onCreate(savedInstanceState); |
04 | setContentView(R.layout.main); |
05 | int ht; |
06 | int wt; |
07 | DisplayMetrics displaymetrics = new DisplayMetrics(); |
08 | getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
09 | ht = displaymetrics.heightPixels; |
10 | wt = displaymetrics.widthPixels; |
11 | } |
相关文章推荐
- Get the screen size (screen resolution) in SmartGWT
- android中getLocationInWindow 和 getLocationOnScreen的区别
- android中getLocationInWindow和getLocationOnScreen的区别
- android中getLocationInWindow 和 getLocationOnScreen的区别
- getLocationInWindow getLocationOnScreen 获取Android坐标
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen
- how to get the space size of some tables in one database?
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen
- 我的Android进阶之旅------>android中getLocationInWindow 和 getLocationOnScreen的差别
- android中getLocationInWindow 和 getLocationOnScreen的区别
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen
- android获得控件在屏幕中的绝对坐标 getLocationInWindow 和 getLocationOnScreen
- Android中getLocationOnScreen和getLocationInWindow 获取屏幕大小
- how to get the space size of some tables in one database?
- android中getLocationInWindow 和 getLocationOnScreen的区别
- Android中getLocationOnScreen和getLocationInWindow 获取屏幕大小
- Xamarin.Android Get Screen size