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