Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 Imageview 我正在动态创建它,现在我正在设置
imageView.setImageBitmap(bitmap); imageView.setBackgroundResource(R.drawable.a);
随着位图大小的增加,setBackgroundResource 图像正在拉伸。
为什么会这样?有什么解决方法吗?
背景资源旨在填满整个 View,这就是为什么当 View 的内容增加时它会被拉伸。
一种可能的解决方法是使用 9-patch 可绘制对象,仅由您指定拉伸。
另一种解决方法是随着普通视图内容的增加缩放背景,并将其重置为新背景。