Android Kitkat 4.4.2 ImageView setBackgroundResource不工作?

Android Kitkat 4.4.2 ImageView setBackgroundResource不工作?,android,imageview,background-image,Android,Imageview,Background Image,今天我遇到了一个奇怪的问题,ImageView.setBackgroundResource()在android kitkat 4.4.2中不起作用,但在其他版本中工作正常。我就是这样使用它的: imageView.setBackgroundResource(R.drawable.imageview_border); 这是可绘制的: <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schem

今天我遇到了一个奇怪的问题,ImageView.setBackgroundResource()在android kitkat 4.4.2中不起作用,但在其他版本中工作正常。我就是这样使用它的:

imageView.setBackgroundResource(R.drawable.imageview_border);
这是可绘制的:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <stroke
        android:width="6dip"
        android:color="@color/brown" />

    <padding
        android:bottom="6dip"
        android:left="6dip"
        android:right="6dip"
        android:top="6dip" />

</shape>

我找了很多,但没能解决这个问题。我不知道4.4.2中是否有其他人面临这个问题,除了我。请帮帮我。

用这个

imageView.setImageResource(R.drawable.imageview_border);
而不是这个

imageView.setBackgroundResource(R.drawable.imageview_border);

它会起作用。

您是否尝试过使用
imageView.setBackground(R.drawable.imageView\u border)???@SweetWisherツ 同样的结果。这根本不起作用ツ .setBackground接受一个可绘制的而不是资源id。然后他可以尝试使用
imageView.setBackground(getResources().getDrawable(R.drawable.imageView_border))@TheLittleNaruto。然后你应该用适当的指导回复他:)@SweetWisherツ