标签:android style blog color os io cti div
package com.kale.screen; 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") @Override protected 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); //推荐的获取屏幕长宽的方式,但需要API13 Display 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); } }
Android中获取屏幕长宽的方法,布布扣,bubuko.com
标签:android style blog color os io cti div
原文地址:http://www.cnblogs.com/tianzhijiexian/p/3871440.html