我在imageView中添加了一个动画gif图像.我无法将其视为gif图像.没有动画.它看起来像一个静止图像.我想知道如何将其显示为gif图像.
我正在尝试在 jetpack compose 中进行聊天,并且希望能够使用三星上的标准 gif 键盘发送 gif。
当我在普通文本字段上单击 GIF 时,我当前收到一条消息“无法在此处输入此内容”
我发现了一个叫做Commit Content API的东西,它应该可以在旧的 EditText 中添加 GIF,所以我在 AndroidView 中尝试,现在我不再收到错误消息,但我也不知道 GIF 在哪里是什么以及它是如何表示的。
AndroidView(factory = {
val editText = @SuppressLint("AppCompatCustomView")
object : EditText(it) {
override fun setOnReceiveContentListener(
mimeTypes: Array<out String>?,
listener: OnReceiveContentListener?
) {
super.setOnReceiveContentListener(mimeTypes, listener)
}
override fun onCreateInputConnection(editorInfo: EditorInfo): InputConnection {
val ic: InputConnection = super.onCreateInputConnection(editorInfo)
EditorInfoCompat.setContentMimeTypes(editorInfo, arrayOf("image/gif"))
val callback =
InputConnectionCompat.OnCommitContentListener { inputContentInfo, _, _ ->
try {
inputContentInfo.requestPermission()
} catch (e: Exception) {
return@OnCommitContentListener false
}
true …Run Code Online (Sandbox Code Playgroud)