android去掉标题栏、信息栏、获取屏幕分辨率、图片全屏

刚学习android不久,打算工作之余做个小应用
本次实现目标:点击应用图标后,全屏显示一张图片,然后初始化应用程序
public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		// 去掉标题栏
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		// 去掉信息栏
		// this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
		// WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.premain);
		// 获取屏幕的分辨率
		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		int screenWidth = dm.widthPixels;
		int screenHeight = dm.heightPixels;
		String str = "分辨率" + screenWidth + "*" + screenHeight;
		Toast.makeText(this, str, Toast.LENGTH_LONG).show();
		imageView = (ImageView) findViewById(R.id.preMainImg);


		Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
		        R.drawable.koala);
		
		// BitmapDrawable bd = new BitmapDrawable(bitmap);
		// bd.setTileModeXY(TileMode.CLAMP , TileMode.CLAMP );
		// bd.setDither(true);
		// imageView.setBackgroundDrawable(bd);


		// 获取这个图片的宽和高
		int imgWidth = bitmap.getWidth();
		int imgHeight = bitmap.getHeight();
		
		// 计算缩放率,新尺寸除原始尺寸
		float scaleWidth = ((float) screenWidth) / imgWidth;
		float scaleHeight = ((float) screenHeight) / imgHeight;


		// 创建操作图片用的matrix对象
		Matrix matrix = new Matrix();


		// 缩放图片动作
		matrix.postScale(scaleWidth, scaleHeight);
		// 旋转图片 动作
		// matrix.postRotate(45);
		// 创建新的图片
		Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, imgWidth,
				imgHeight, matrix, true);


		BitmapDrawable bd = new BitmapDrawable(resizedBitmap);
		bd.setTileModeXY(TileMode.CLAMP, TileMode.CLAMP);
		bd.setDither(true);


		imageView.setBackgroundDrawable(bd);


	}









  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值