【问题标题】:Applying shadow to transparent image in Android在Android中将阴影应用于透明图像
【发布时间】:2021-12-17 16:21:22
【问题描述】:

有没有办法将 shadowRadius 应用于 Android 中的透明 ImageView?对于 TextView,以下工作:

<TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:shadowColor="@color/textShadowColor"
                    android:shadowRadius="15"
                    android:shadowDx="0"
                    android:shadowDy="0" />

如何在 Android 中为放置在文本旁边的箭头图标实现相同的效果?在 iOS 中,以下工作开箱即用:

Image("arrow")
  .shadow(color: textShadowColor, radius: textShadowRadius, x: 0.0, y: 0.0)
Text("my text")
  .shadow(color: textShadowColor, radius: textShadowRadius, x: 0.0, y: 0.0)

【问题讨论】:

  • 您想让箭头本身投下阴影吗?还是imageview的轮廓?是位图还是矢量?
  • 箭头本身,效果和文字一样。这是一个png。
  • 这在 Android 中可能是可行的。这种效果是应用于不确定数量的 PNG 还是预先知道的有限数量?如果事先知道,您可以简单地使用 Adob​​e Illustrator 或 Gimp 来制作阴影并将它们存储在您的 APK 中。
  • > “这在 Android 中可能是可行的。”我正在等待所有 Android 专家来阐明它。

标签: android imageview shadow


【解决方案1】:

这应该可以解决问题。它被用作文本的一种属性。

android:outlineProvider="bounds"

我从:https://www.codegrepper.com/code-examples/java/android%3Aoutlineprovider%3D%22bounds%22获得此信息

【讨论】:

  • 它不会使 ImageView 支持 "android:shadowRadius="15"" 属性。显然它在 Android 中不受支持。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-08
  • 2011-03-31
  • 1970-01-01
  • 2011-01-09
相关资源
最近更新 更多