第一种不去区分版本,使用V4包的android.support.v4.graphics.drawable.DrawableCompat

ImageView image = new ImageView(context);Drawable up = ContextCompat.getDrawable(context,R.drawable.ic_sort_up);Drawable drawableUp= DrawableCompat.wrap(up);DrawableCompat.setTint(drawableUp, ContextCompat.getColor(context,R.color.theme));image.setImageDrawable(drawableUp);

第二种只能在API21以上使用

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {             ImageView image = new ImageView(context);    image.setImageResource(R.drawable.ic_sort_down);    image.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(context,R.color.theme)));}

更多相关文章

  1. 应用内版本更新库UpdateVersion
  2. Android 获取未安装的APK图标、版本号、包名等信息
  3. Android版本检测/自动更新
  4. Rockchip查看Android SDK版本
  5. Android 深入研究SQLite实例(一) 之 业务类 sqlite版本管理类
  6. Android和Linux版本对应
  7. Android 版本及别名
  8. android 各个版本介绍(截止2017年)
  9. Android api对应版本(持续更新)

随机推荐

  1. Android使用WebView.loadUri()打开网页的
  2. Android编程开发录音和播放录音简单示例
  3. android之Pull解析XML
  4. Android实现记事本小功能
  5. 小白的App开发日志-使用Kotlin开发App -
  6. Android Client and PHP Server
  7. android不自动弹出虚拟键盘
  8. Android studio -SVN 的简单介绍
  9. 随手记----Android仿iOS音量调节的效果
  10. Android Studio 3.6运行模拟器Emulator警