【问题标题】:Android How I Can AppWidget Play Gif?Android 我如何 AppWidget 播放 Gif?
【发布时间】:2017-04-30 19:04:49
【问题描述】:

使用滑翔库。 这就像正常的图片。 我尝试了 glide 库,但它不起作用。 使用滑动库。 这就像正常的图片。 我尝试了滑翔库,但它不起作用。

 public class NewAppWidget extends AppWidgetProvider {
    private static AppWidgetTarget appWidgetTarget;

static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {

    CharSequence widgetText = NewAppWidgetConfigureActivity.loadTitlePref(context, appWidgetId);
    // Construct the RemoteViews object
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);
    views.setTextViewText(R.id.appwidget_text, widgetText);
    RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);

    appWidgetTarget = new AppWidgetTarget( context, rv, R.id.imageView, appWidgetId );

    Glide
            .with( context.getApplicationContext() ) // safer!
            .load("https://i.giphy.com/l4FGq1K2WUMWYSisw.gif")
            .asBitmap()
            .into(appWidgetTarget);
    pushWidgetUpdate(context, rv);

    appWidgetManager.updateAppWidget(appWidgetId, rv);
}
public static void pushWidgetUpdate(Context context, RemoteViews rv) {
    ComponentName myWidget = new ComponentName(context, NewAppWidget.class);
    AppWidgetManager manager = AppWidgetManager.getInstance(context);
    manager.updateAppWidget(myWidget, rv);
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // There may be multiple widgets active, so update all of them
    for (int appWidgetId : appWidgetIds) {
        updateAppWidget(context, appWidgetManager, appWidgetId);

        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);

        appWidgetTarget = new AppWidgetTarget( context, rv, R.id.imageView, appWidgetIds );

        Glide
                .with( context.getApplicationContext() ) // safer!
                .load("https://i.giphy.com/l4FGq1K2WUMWYSisw.gif")
                .asBitmap()
                .into(appWidgetTarget);
        pushWidgetUpdate(context, rv);
    }

}

我的英语不好,我已经道歉了,我可以告诉你我可以告诉你。 谢谢

【问题讨论】:

标签: android android-widget


【解决方案1】:

ImageView 不显示动画 GIF 的动画。没有任何小部件可以进入将播放动画 GIF 动画的应用小部件。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2016-04-06
  • 2011-11-10
  • 2020-01-07
  • 2016-12-17
  • 2014-12-29
  • 2013-12-23
  • 2022-11-14
  • 1970-01-01
相关资源
最近更新 更多