简体   繁体   English

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

[英]Android Kitkat 4.4.2 ImageView setBackgroundResource not working?

Today i came through a strange problem that ImageView.setBackgroundResource() is not working in android kitkat 4.4.2, but it is working fine in other versions. 今天,我遇到了一个奇怪的问题,即ImageView.setBackgroundResource()在android kitkat 4.4.2中无法正常工作,但在其他版本中却可以正常工作。 This is how i am using it: 这就是我的使用方式:

imageView.setBackgroundResource(R.drawable.imageview_border);

This is the drawable: 这是可绘制的:

<?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>

I have searched a lot but did not able to solve the problem. 我进行了很多搜索,但未能解决问题。 I don't know whether someone else is facing this problem in 4.4.2 except me or not. 我不知道除了我以外,是否有人在4.4.2中正面临这个问题。 Please help me. 请帮我。

Use this 用这个

imageView.setImageResource(R.drawable.imageview_border);

Instead of this 代替这个

imageView.setBackgroundResource(R.drawable.imageview_border);

It will work. 它会工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 系统生成的缩略图检索在自定义Android KitKat 4.4.2中无法正常工作 - System generated thumbnail retrieval not working properly in custom Android KitKat 4.4.2 ListView setBackgroundResource无法正常工作 - ListView setBackgroundResource not working android Android Kitkat 4.4.2:自适应播放对SurfaceFlinger的影响 - Android Kitkat 4.4.2: Adaptive Playback impact on SurfaceFlinger Android DigitalClock在Kitkat 4.4.2中不显示秒 - Android DigitalClock not displaying seconds in Kitkat 4.4.2 android开关样式不适用于KitKat(4.4.2) - android switch style is not applied on KitKat (4.4.2) Android 4.4.2 Kitkat无法使用HttpURLConnection发送请求 - Android 4.4.2 Kitkat can not send a request with HttpURLConnection 在webview android kitkat 4.4.2上“选择要上传的文件” - “choose file to upload” on webview android kitkat 4.4.2 在Android 4.4.2 KitKat中使用moveTaskToBack覆盖后退按钮 - Override back button with moveTaskToBack in Android 4.4.2 KitKat AlarmManager在Android版本4.4.2 KitKat中触发两次 - AlarmManager fires twice in Android Version 4.4.2 KitKat android imageview.setBackgroundResource()不起作用 - android imageview.setBackgroundResource() doesn't work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM