在我的下一个项目中,我希望按钮效果或动画像这样,当用户点击按钮或拖动悬停按钮。
我做了太多的研究,但我什么也没找到。
我想要这样的按钮效果。
请帮我解决这个问题。
提前谢谢。
发布于 2015-07-25 19:03:09
要创建类似于您的示例的动画,您肯定需要实现自定义动画。请在此处查找详细信息:
https://developer.android.com/training/material/animations.html
此外,您还应该检查现有的库,这些库可能会带来类似的效果。不错的库源:
发布于 2015-07-25 14:12:34
这是按钮效果的基本动画:http://android-er.blogspot.com/2012/02/apply-animation-on-button.html
发布于 2015-07-26 21:37:12
我认为你应该使用"FrameLayout“clickable和inside 使用imageview,然后你就可以很容易地对图像进行动画处理。
Structure
<FrameLayout
//set the properties + must set clickable property
>
<ImageView
// Set the required property
/>
</FrameLayout>
然后设置单击侦听器的帧布局和你需要在.java文件中动画imageview的地方。
在动画文件夹中创建动画xml
my_anim.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite" />
然后在.java文件中使用下面给出的图像视图调用它,以便平滑地旋转图像。
Animation a = AnimationUtils.loadAnimation(getActivity(), R.anim.my_anim);
a.setDuration(1000);
myImageView.startAnimation(a);
a.setInterpolator(new Interpolator() {
private final int frameCount = 50;
@Override
public float getInterpolation(float input) {
return (float) Math.floor(input * frameCount) / frameCount;
}
});
https://stackoverflow.com/questions/31480361
复制相似问题