鸟语天空
判断屏幕方向
post by:追风剑情 2015-7-22 22:03
package com.example.androidtest;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;

public class OrientationActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_orientation);
		
		//判断屏幕方向
		WindowManager wm = getWindowManager();
		Display d = wm.getDefaultDisplay();
		if(d.getWidth() > d.getHeight()){
			Log.d("Orientation", "Landscape mode");
		}else{
			Log.d("Orientation", "Portrait mode");
		}
	}
}
评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容