我正在尝试在我的应用中使用GIF时遇到问题。当我运行我的应用程序时,它只是没有出现。我按照如何使其工作的教程,所以我不知道为什么它没有。我也没有收到任何错误消息。所以,我的问题是,是否有人对此为何发生了什么建议?在此先感谢您的帮助!我的代码:buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
}}allprojects
{
repositories {
mavenCentral()
google()
jcenter()
}}App build script:dependencies {
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'}XML:
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="60dp"
app:srcCompat="@drawable/gif" />
2 回答
收到一只叮咚
TA贡献1821条经验 获得超5个赞
试试这个:
XML:
<pl.droidsonroids.gif.GifImageView
android:id="@+id/gif_view_offer"
android:layout_gravity="center"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="20dp"
android:src="@drawable/checkmark"
android:layout_marginBottom="10dp"/>
JAVA:
GifImageView gifView;
GifDrawable gifFromResource = null;
gifView = (GifImageView) v.findViewById(R.id.gif_view_offer);
try {
gifFromResource = new GifDrawable(activity.getResources(), R.drawable.lockgif);
gifView.setImageDrawable(gifFromResource);
} catch (IOException e) {
gifView.setVisibility(View.GONE);
e.printStackTrace();
}添加回答
举报
0/150
提交
取消
