Android UI Libs之android-gif-drawable

Android UI Libs之android-gif-drawable


我们经常需要显示gif图片,但是Android自带的ImageView不能完全显示gif图片,它只会显示gif图片的第1帧。那我们要显示gif图片怎么办。本着不重复“造轮子”的原则,本人推荐使用android-gif-drawable。android-gif-drawabl的功能很强大,不仅可以在显示gif图片,还可以让gif图片作为文本和按钮的背景图片显示等。

要使用 android-gif-drawabl,首先要添加依赖compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15'

显示gif图片:

        <pl.droidsonroids.gif.GifImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@drawable/image"
        />  

以gif图片作为文本的背景图片:

        <pl.droidsonroids.gif.GifTextView
        android:text="hello"
        android:background="@drawable/image"
        android:layout_width="100dp"
        android:layout_height="100dp" />  

以gif图片作为文按钮的背景图片:

        <pl.droidsonroids.gif.GifImageButton
        android:text="hello"
        android:background="@drawable/image"
        android:layout_width="100dp"
        android:layout_height="100dp" />  

程序源代码下载,我的github仓库:https://github.com/lavor-zl/UILibs

欢迎关注我的简书专题:Android技术漫谈
欢迎关注我的微信公众号:Android技术漫谈

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
非常抱歉,我的失误。实际上,`Assets/Plugins/Android/libs/arm64-v8a/libil2cpp.so`是一个假路径,需要根据实际情况进行替换。在Unity工程中,`libil2cpp.so`文件的实际路径由以下两个因素决定: 1. 在Unity中,需要将工程选择为IL2CPP脚本后端,才能生成`libil2cpp.so`文件。在菜单栏中选择`Edit` -> `Project Settings` -> `Player`,然后在`Other Settings`中选择`Scripting Backend`为`IL2CPP`即可。 2. 在工程目录下,`libil2cpp.so`文件实际上是在`/Library/ScriptAssemblies`目录下生成的。因此,正确的路径应该是`/Library/ScriptAssemblies/libil2cpp.so`。如果你的工程中有多个CPU架构需要支持,`libil2cpp.so`文件可能会分别拷贝到不同的文件夹下,如`/Library/ScriptAssemblies/arm64-v8a/libil2cpp.so`、`/Library/ScriptAssemblies/armeabi-v7a/libil2cpp.so`等。在脚本中需要根据实际情况进行替换。 以下是修改后的脚本代码: ```csharp using UnityEditor; using UnityEditor.Android; public static class MyBuildScript { [MenuItem("Build/Build Android")] public static void BuildAndroid() { // 设置 APK 导出路径 string apkPath = "Build/MyGame.apk"; // 生成 Android 工程 string error = BuildPipeline.BuildPlayer(new string[] {"Assets/Main.unity"}, apkPath, BuildTarget.Android, BuildOptions.None); if (!string.IsNullOrEmpty(error)) { Debug.LogError(error); return; } // 导出 libil2cpp.so 文件 string il2cppPath = "/Library/ScriptAssemblies/libil2cpp.so"; // 根据实际情况进行修改 string destPath = "Build/MyGame/libs/arm64-v8a/libil2cpp.so"; // 根据实际情况进行修改 FileUtil.CopyFileOrDirectory(il2cppPath, destPath); // 打开 APK 导出目录 EditorUtility.RevealInFinder(apkPath); } } ``` 希望这次能为您解答问题,如果还有其他问题,请随时问我。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值