gpt4 book ai didi

Android按钮动画

转载 作者:行者123 更新时间:2023-12-04 02:18:27 26 4
gpt4 key购买 nike

我这里有这些按钮,我希望它们都有一些点击动画。长大一点,然后恢复正常。

这是按钮的 xml 代码。

<ImageButton
android:layout_width="165dp"
android:layout_height="60dp"
android:text="next"
android:id="@+id/next"
android:src="@drawable/next"
android:background="@android:color/transparent"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/linearLayout"
android:layout_alignEnd="@+id/linearLayout" />

<ImageButton
android:layout_width="170dp"
android:layout_height="60dp"
android:text="confirm"
android:src="@drawable/confirm"
android:background="@android:color/transparent"
android:id="@+id/confirm"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
/>

这些按钮位于同一个 activity_main.xml 文件中。

谁能帮我看看我应该怎么做才能实现它?

非常感谢您的宝贵时间。

最佳答案

使用Animator可以轻松达到目的:

findViewById(R.id.next).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animator scale = ObjectAnimator.ofPropertyValuesHolder(v,
PropertyValuesHolder.ofFloat(View.SCALE_X, 1, 1.5f, 1),
PropertyValuesHolder.ofFloat(View.SCALE_Y, 1, 1.5f, 1)
);
scale.setDuration(1000);
scale.start();
}
});

关于Android按钮动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32626315/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com