以背景的形式 进行设置图片
缺点 : 图片容易变形 优点: 可以不用关心图片的大小 直接填充窗体
image2
.setBackground(getResources()
.getDrawable(R
.drawable.blackk))
image2
.setBackgroundResource(R
.drawable.blackk)
image2
.setBackgroundDrawable(getResources()
.getDrawable(R
.drawable.blackk))
以 设置图片 的形式设置资源
缺点 : 与窗体不能完美结合 优点: 图片不会变形
image2
.setImageDrawable(getResources()
.getDrawable(R
.drawable.blackk))
String path=Environment
.getExternalStorageDirectory()+File
.separator+
"test1.jpg"
Bitmap bm = BitmapFactory
.decodeFile(path)
image2
.setImageBitmap(bm)
image2
.setImageResource(R
.drawable.blackk)
安卓交流群 : 595856941
转载请注明原文地址: https://ju.6miu.com/read-970675.html