要确保ImageView的背景不改变,可以使用以下解决方法:
ImageView imageView = findViewById(R.id.imageView);
imageView.setBackgroundColor(Color.TRANSPARENT);
ImageView imageView = findViewById(R.id.imageView);
imageView.setImageDrawable(getResources().getDrawable(R.drawable.image));
请注意,上述代码示例中的R.drawable.image是一个示例图片资源,你需要替换为你自己的图片资源。
上一篇:Android:IllegalArgumentException:层级中有两个视图具有相同的ID。
下一篇:Android:IndexOutOfBoundsException异常,length=36;index=-1引起的崩溃