Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中放大和缩小动画_Android_Android Layout_Android Intent_Android Animation - Fatal编程技术网

在android中放大和缩小动画

在android中放大和缩小动画,android,android-layout,android-intent,android-animation,Android,Android Layout,Android Intent,Android Animation,我有代码,通常放大和缩小两个活动之间的动画,但我想要一些不同的东西。我有五个按钮在我的第一个活动,若我点击第一个按钮,那个么放大将只从第一个按钮的位置开始,而不是从中心放大。请帮帮我 编辑:缩放应该从我点击的按钮开始,作为中心。我想你必须做如下操作 设置“输入”和“输出”动画 创建文件夹res/anim 将动画描述放入res/anim文件夹 object.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.zoom_enter));

我有代码,通常放大和缩小两个活动之间的动画,但我想要一些不同的东西。我有五个按钮在我的第一个活动,若我点击第一个按钮,那个么放大将只从第一个按钮的位置开始,而不是从中心放大。请帮帮我


编辑:缩放应该从我点击的按钮开始,作为中心。

我想你必须做如下操作

  • 设置“输入”和“输出”动画
  • 创建文件夹res/anim
  • 将动画描述放入res/anim文件夹

    object.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.zoom_enter));
    setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.zoom_exit))

您可以使用谷歌在Apache2.0许可下提供的android sdk示例动画

或者参考这个,它使用基于缩放的缩放,这比前者更容易


您可以在运行命令后使用此方法启动新活动

startActivity(意图);
覆盖转换(动画在这里进入,动画在这里离开);
然后,您可以替换上面的动画,用您新开始的活动所需的动画资源替换此处的动画,并用您即将离开的活动的动画资源替换此处的动画。这将为您提供切换效果

放大.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
    <scale
    android:duration="1000"
    android:fromXScale="1"
    android:fromYScale="1"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="3"
    android:toYScale="3"/>
 </set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
    <scale
    android:duration="1000"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="0.5"
    android:toYScale="0.5"/>
</set>

缩小.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
    <scale
    android:duration="1000"
    android:fromXScale="1"
    android:fromYScale="1"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="3"
    android:toYScale="3"/>
 </set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
    <scale
    android:duration="1000"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="0.5"
    android:toYScale="0.5"/>
</set>

希望这有助于回答你的问题

放大


缩小



您的问题不太清楚,您想从布局的中心放大,还是动画工作不正常?我有五个按钮,当我单击任何按钮时,它将展开并开始下一个活动。您不想开始新活动?我也想开始新活动。但动画将类似于扩展Hnax…但动画并不合适:(怎么会这样?问题似乎是什么?这个动画不正确。我要离开的活动没有发生任何转换。我要切换到的活动,首先放大,然后切换回正常状态。我要离开的活动没有发生任何变化。我失去了任何依赖关系吗?这个答案到现在为止有8个拇指,所以在c中必须是正确的。)如何在一个屏幕上同时显示两种效果?创建zoom.xml这是用于缩小和放大的,以便在一个屏幕上同时显示两种效果?