package com.kale.imageview02;import android.annotation.SuppressLint;import android.app.Activity;import android.graphics.Point;import android.os.Bundle;import android.util.Log;import android.view.Display;public class MainActivity extends Activity {@SuppressLint("NewApi")@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);int dw = getWindowManager().getDefaultDisplay().getWidth();//获得手机屏幕的宽度int dh = getWindowManager().getDefaultDisplay().getHeight();//获得手机屏幕的高度Log.i("h", "height:"+dw);Log.i("w", "width:"+dh);//推荐的获取屏幕长宽的方式,但需要API13Display display = getWindowManager().getDefaultDisplay();Point size = new Point();display.getSize(size);int windowHeight = size.y;int windowWidth = size.x;Log.i("w","width:"+ windowWidth);Log.i("h", "height:"+ windowHeight);}}

更多相关文章

  1. [Android问答] 如何获得手机屏幕分辨率?
  2. Android 获取控件高度宽度三种方法,防止0的出现
  3. Android 获取手机屏幕大小两种方法
  4. Android Dialog在底部显示且宽度match_parent
  5. Android 代码获取手机屏幕分辨率的代码
  6. Android--取得控件在手机屏幕上的位置
  7. android中获取文字的宽度
  8. Android百分比布局(PercentRelativeLayout)嵌套NavigationView自
  9. android中关于手机屏幕的相关操作(获取屏幕的宽高等操作)

随机推荐

  1. android CTS测试使用方法
  2. Android菜鸟笔记-获取设备信息
  3. 让Android studio支持java8
  4. Android 图片资源的异步加载2
  5. android 常用调用系统功能
  6. Android源码去除状态栏
  7. android http中请求访问添加 cookie
  8. android 获取当前手机的 DHCP 信息ip,ser
  9. MVP框架搭建
  10. Android开发常见问题 不定期更新。开发环