【发布时间】:2017-07-14 05:06:10
【问题描述】:
以下是我的 zoom_in.xml
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="0"
android:fromYScale="0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1" >
</scale>
</set>
视图放大三倍。我怎样才能做到一次呢
PS:android:repeatCount="1" 不工作。
编辑1:我的动画Util有加载动画如下
public static Animation loadAnimation(Context context, @AnimRes int id)
throws NotFoundException {
XmlResourceParser parser = null;
try {
parser = context.getResources().getAnimation(id);
return createAnimationFromXml(context, parser);
} catch (XmlPullParserException ex) {
NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" +
Integer.toHexString(id));
rnf.initCause(ex);
throw rnf;
} catch (IOException ex) {
NotFoundException rnf = new NotFoundException("Can't load animation resource ID #0x" +
Integer.toHexString(id));
rnf.initCause(ex);
throw rnf;
} finally {
if (parser != null) parser.close();
}
现在我把它称为如下
zoomIn = loadAnimation(getContext(),
R.anim.zoom_in);
view.startAnimation(zoomIn);
【问题讨论】:
-
不提
android:repeatCount='"1"怎么办 -
还可以尝试在代码中添加
AnimationListener并在onAnimationEnd方法中停止动画。 -
如果我不提及重复计数,它会放大 3 倍。如果我输入重复计数,它也会重复 3 次。
-
给我看你的java代码并尝试第二个选项..
-
@ELITE 请检查我的代码是否有任何错误?
标签: android android-layout android-animation