<tfoot id='gFvof'></tfoot>

      <i id='gFvof'><tr id='gFvof'><dt id='gFvof'><q id='gFvof'><span id='gFvof'><b id='gFvof'><form id='gFvof'><ins id='gFvof'></ins><ul id='gFvof'></ul><sub id='gFvof'></sub></form><legend id='gFvof'></legend><bdo id='gFvof'><pre id='gFvof'><center id='gFvof'></center></pre></bdo></b><th id='gFvof'></th></span></q></dt></tr></i><div id='gFvof'><tfoot id='gFvof'></tfoot><dl id='gFvof'><fieldset id='gFvof'></fieldset></dl></div>
      <legend id='gFvof'><style id='gFvof'><dir id='gFvof'><q id='gFvof'></q></dir></style></legend>

        <bdo id='gFvof'></bdo><ul id='gFvof'></ul>

      <small id='gFvof'></small><noframes id='gFvof'>

    1. Android 小部件:RemoteViews 上的动画?

      时间:2023-09-09
      <i id='ps9iy'><tr id='ps9iy'><dt id='ps9iy'><q id='ps9iy'><span id='ps9iy'><b id='ps9iy'><form id='ps9iy'><ins id='ps9iy'></ins><ul id='ps9iy'></ul><sub id='ps9iy'></sub></form><legend id='ps9iy'></legend><bdo id='ps9iy'><pre id='ps9iy'><center id='ps9iy'></center></pre></bdo></b><th id='ps9iy'></th></span></q></dt></tr></i><div id='ps9iy'><tfoot id='ps9iy'></tfoot><dl id='ps9iy'><fieldset id='ps9iy'></fieldset></dl></div>
      • <bdo id='ps9iy'></bdo><ul id='ps9iy'></ul>

        <small id='ps9iy'></small><noframes id='ps9iy'>

      • <legend id='ps9iy'><style id='ps9iy'><dir id='ps9iy'><q id='ps9iy'></q></dir></style></legend>
        1. <tfoot id='ps9iy'></tfoot>

                <tbody id='ps9iy'></tbody>
                本文介绍了Android 小部件:RemoteViews 上的动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                将动画应用于 RemoteViews 内的视图并没有取得太大成功.

                I'm not having too much success applying animations to views inside a RemoteViews.

                为了简单起见,假设我有一个带有 ImageViewButton 的小部件.单击按钮时,我想向 ImageView 添加一个简单的动画(例如旋转).

                For the sake of simplicity, let's say I have a widget with an ImageView and a Button. When clicking the button, I want to add a simple animation to the ImageView (a rotation for example).

                由于我无法像在 Activity 中那样使用 findViewById() 获得参考,并且 RemoteViews 没有设置器动画,我不知道该怎么办.

                Since I can't get a reference using findViewById() like in an Activity and RemoteViews doesn't have a setter for an animation, I'm not sure what should I do.

                我正在考虑用新布局替换小部件的 RemoteViews,类似于原始布局,但这个布局已经加载了动画.我可以这样做吗?是否可以在布局中嵌入动画?

                I'm thinking of replacing the RemoteViews for the widget with a new layout, similar to the original but this one has the animation already loaded. Can I do this? Is it possible to embed an animation in a layout?

                WidgetProvider 的代码如下所示:

                Code would be something like this for the WidgetProvider:

                Intent intent = new Intent(context, RotateService.class);
                PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);
                
                RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.a_widget);
                views.setOnClickPendingIntent(R.id.a_button, pendingIntent);
                
                appWidgetManager.updateAppWidget(appWidgetId, views);
                

                然后在RotateService中:

                Then in RotateService:

                ComponentName myWidget = new ComponentName(this, MyWidget.class);
                AppWidgetManager manager = AppWidgetManager.getInstance(this);
                RemoteViews newViews = buildNewRemoteViewsWithAnimation();
                manager.updateAppWidget(myWidget, newViews);
                

                还有什么建议吗?

                推荐答案

                1. 创建自定义动画.
                2. 创建 ProgressBar 并在 android:indeterminateDrawable 中设置您的动画.
                3. 将 ProgressBar 添加到您的小部件布局并使其可见(不可见)

                这篇关于Android 小部件:RemoteViews 上的动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如果我尝试启动服务,为什么会收到 InstantiationException? 下一篇:以编程方式更改小部件布局

                相关文章

                1. <i id='Pknap'><tr id='Pknap'><dt id='Pknap'><q id='Pknap'><span id='Pknap'><b id='Pknap'><form id='Pknap'><ins id='Pknap'></ins><ul id='Pknap'></ul><sub id='Pknap'></sub></form><legend id='Pknap'></legend><bdo id='Pknap'><pre id='Pknap'><center id='Pknap'></center></pre></bdo></b><th id='Pknap'></th></span></q></dt></tr></i><div id='Pknap'><tfoot id='Pknap'></tfoot><dl id='Pknap'><fieldset id='Pknap'></fieldset></dl></div>
                  1. <legend id='Pknap'><style id='Pknap'><dir id='Pknap'><q id='Pknap'></q></dir></style></legend>
                  2. <tfoot id='Pknap'></tfoot>
                      <bdo id='Pknap'></bdo><ul id='Pknap'></ul>

                    <small id='Pknap'></small><noframes id='Pknap'>