【问题标题】:'image-rendering: pixelated;' like on ImageView?'图像渲染:像素化;'像在 ImageView 上?
【发布时间】:2022-01-05 14:53:06
【问题描述】:

使用 CSS,您可以使用 'image-rendering: pixelated;' 为 img 标签添加样式。

有没有办法在Android中实现类似的效果?

【问题讨论】:

    标签: android imageview


    【解决方案1】:

    您可以通过将 setFilterBitmap(false) 设置为 Drawable 对象(或使用 Canvas 时为 Paint 对象)来实现(关闭抗锯齿功能)。

    Drawable drawable = getDrawable(R.drawable.sample);
    drawable.setFilterBitmap(false);
    
    ImageView imageView = findViewById(R.id.imageView);
    imageView.setImageDrawable(drawable);
    

    【讨论】:

      猜你喜欢
      • 2021-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-07
      • 1970-01-01
      • 2020-06-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多