相关疑难解决方法(0)

Android动画旋转

我在Android代码中进行了一些挖掘,并在不确定的进度条中看到了它的使用.尝试使用此标记创建自己的drawable后:

<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/spinner_pia"
    android:pivotX="50%"
    android:pivotY="50%"
    android:framesCount="12"
    android:frameDuration="100" />
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:"没有找到包''android'中属性'frameDuration'的资源标识符" - 这意味着frameDuration是一个私有属性.有没有办法使用这个"动画旋转"功能?

我的任务是替换系统的默认不确定进度条.我想尽可能少地编写代码(如果可能的话,只需更改一些属性).使用ProgressBar视图,设置:

android:indeterminateOnly="true"
android:indeterminateBehavior="cycle"
android:indeterminateDuration="3500"
android:indeterminateDrawable="@drawable/pia_sivuvator"
Run Code Online (Sandbox Code Playgroud)

并指向该对象的"@ drawable/pia_sivuvator"将使我的任务变得优雅,但我仍然坚持这些私有属性.

救命?

customization animation android progress-bar

53
推荐指数
4
解决办法
7万
查看次数

Android主屏幕小部件动画

我正在寻找创建一个支持动画的小部件,理想情况下通过android.view.animation框架,否则通过在后台服务触发的代码中设置远程视图的属性.

有没有人对这些方法中的任何一种都有任何经验,而且我正在尝试做什么,或者我是否正在走向死胡同?

animation android android-widget

32
推荐指数
1
解决办法
1万
查看次数

Android Widgets:RemoteViews上的动画?

我没有太多成功将动画应用于视图中的视图RemoteViews.

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

因为我不能findViewById()像在an中那样使用Activity并且RemoteViews没有动画的setter,所以我不知道该怎么办.

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

对于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);
Run Code Online (Sandbox Code Playgroud)

然后在RotateService中:

ComponentName myWidget = new ComponentName(this, MyWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
RemoteViews newViews = buildNewRemoteViewsWithAnimation();
manager.updateAppWidget(myWidget, newViews);
Run Code Online (Sandbox Code Playgroud)

还有其他建议吗?

animation android widget android-widget

22
推荐指数
1
解决办法
2万
查看次数

在窗口小部件中动画.png图像

问题描述


我正在为Android 编写一个简单的Widget应用程序,在我的Widget I Layout中,我可以ImageViewRefresh控制我已经设置了Refresh Image Picture(下面的绿色图像).


在某些时候,我按下ImageViewRefresh 我的Widget中按钮,应用程序开始从Internet下载一些内容,而应用程序在后台下载数据我想做一些动画,比如旋转我的图像(下面的绿色图像).我能这样做吗?

研究


我已经阅读了一些关于图像动画的帖子,但我只能在应用程序中找到.gif图片的动画,这是一种旋转图像的方法,例如制作一些旋转的图像并更改它们或其他东西.

代码示例

这是layout我的图像代码的一部分不旋转.为什么?(我的形象很简单.png图片)

<ProgressBar
        android:id="@+id/progressBarRefresh"
        android:layout_width="36dp"
        android:indeterminateDrawable="@drawable/arrow_refresh"
        android:layout_height="36dp"
        android:layout_alignTop="@+id/imageViewArrowNext"
        android:layout_marginRight="70dp"
        android:layout_toLeftOf="@+id/textViewAutherName"
        android:indeterminate="true" />
Run Code Online (Sandbox Code Playgroud)

我要旋转的图像.

旋转图像

android android-widget android-animation android-imageview

7
推荐指数
1
解决办法
1989
查看次数