我并没有太多的成功应用动画到 RemoteViews
里面的观点。
I'm not having too much success applying animations to views inside a RemoteViews
.
为简单起见,假设我有一个的ImageView
小部件和按钮
。点击按钮时,我想一个简单的动画添加到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).
由于使用我不能得到一个参考 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?
code会是这样的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);
任何其他建议?
Any other suggestion?
下面是关于这个问题的一些详细信息:
Here's some more information about this issue:
有没有一种方法来在首页动画工具?