方法1:

<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/lbhao" /> 以上是代码:只需加入在ImageView中加入这个代码即可android:scaleType="fitXY"

方法2:

public static Bitmap FitTheScreenSizeImage(Bitmap m,int ScreenWidth, int ScreenHeight)
{
float width = (float)ScreenWidth/m.getWidth();
float height = (float)ScreenHeight/m.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(width,height);
return Bitmap.createBitmap(m, , , m.getWidth(), m.getHeight(), matrix, true);
}
float width = (float)ScreenWidth/m.getWidth(); 屏宽/图宽
float height = (float)ScreenHeight/m.getHeight(); 屏高/图高
Matrix matrix = new Matrix(); 矩阵对象
matrix.postScale(width,height); 把缩放系数传入该对象中
return Bitmap.createBitmap(m, , , m.getWidth(), m.getHeight(), matrix, true); 创建一张图片
参数分别是:
图片对象、x、y、w、h、矩阵对象、是否开启抗锯齿 setContentView(FitTheScreenSizeImage(R.drawable.welcomeview,screenWidth,screenHeigh));}

最新文章

  1. Bootsrap基本应用
  2. servlet(1)
  3. 关于silverlight打印模糊的问题
  4. http://blog.csdn.net/littlechang/article/details/8642149
  5. javascript中的JSON序列化与反序列化
  6. python--列表的使用
  7. Session累计用户数据列表
  8. SQL Server 性能调优 之运行计划(Execution Plan)调优
  9. Filter自动登录
  10. C语言_scanf()和getchar() 使用[粗俗易懂]
  11. Linux显示登入系统的帐号名称和总人数
  12. vector的 []
  13. Diango之通过form表单向服务端发送数据
  14. python测试webservice接口
  15. 实现类似于QQ空间相册的点击图片放大,再点后缩小回原来位置
  16. &quot;ERR unknown command &#39;cluster&#39;&quot;
  17. unity5x --------Music Mixer参数详解
  18. 【Other】最近在研究的, Java/Springboot/RPC/JPA等
  19. Centos7安装Openresty
  20. win10环境配置react

热门文章

  1. Android中ListView同过自定义布局并使用SimpleAdapter的方式实现数据的绑定
  2. 在什么情况下使用struct,struct与class的区别
  3. 使用Horner法则计算多项式的值
  4. openstack 安装
  5. 百度全站变https
  6. C#中对于接口的实现方式
  7. 【C#基础】HTTP发送POST二进制数据
  8. HTTP Status 404(The requested resource is not available)的几种解决方法
  9. 初学者使用IntellJ IDEA建立Struts2项目
  10. MySQL数据库的环境及简单操作