Android Kitkat 4.4.2 ImageView setBackgroundResource无法正常工作?

时间:2014-06-21 11:46:03

标签: 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://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中遇到这个问题。请帮帮我。

1 个答案:

答案 0 :(得分:0)

使用此

imageView.setImageResource(R.drawable.imageview_border);

而不是这个

imageView.setBackgroundResource(R.drawable.imageview_border);

它会起作用。