自定义可以旋转的控件
2017-10-03 21:41
106 查看
public class AnimationUtil { public static void rotateOutAnim(RelativeLayout relativeLayout,long delay){ int childCount=relativeLayout.getChildCount(); for (int i=0;i<childCount;i++){ relativeLayout.getChildAt(i).setEnabled(false); } RotateAnimation ra =new RotateAnimation(0f,-180f, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,1.0f); ra.setDuration(500); ra.setFillAfter(true); ra.setStartOffset(delay); relativeLayout.startAnimation(ra); } public static void rotateInAnim(RelativeLayout relativeLayout){ int childCount=relativeLayout.getChildCount(); for (int i=0;i<childCount;i++){ relativeLayout.getChildAt(i).setEnabled(true); } RotateAnimation ra =new RotateAnimation(-180f,0f, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,1.0f); ra.setDuration(500); ra.setFillAfter(true); relativeLayout.startAnimation(ra); }}
这是用于旋转控件的工具类,首先配置新增一个旋转动画类,传入layout后将layout进行旋转。
需要进行旋转时就找出layout的实例,将其作为参数传入工具类的旋转方法里就行
level2=(RelativeLayout)findViewById(R.id.level2);
AnimationUtil.rotateOutAnim(level2,0);
相关文章推荐
- 自定义可以来回拖拽的控件,通过拖拽改变图片顺序
- Android中如何自定义我们想要的控件(以可以自动获取焦点的TextView为例)
- UI控件 UIActivityIndicatorView 等待时出现的动态旋转图,以及自定义颜色
- android 一个可以自定义的进度条控件
- Flex textinput, 可以输入自定义的item, 类似wow的输入框控件
- Android 在ViewPager中使用的可以画线,放大,保存,点击删除线条的自定义图片显示控件
- 自定义组合控件之——旋转的菜单(老优酷菜单)
- 【Android自定义View实战】之自定义评价打分控件RatingBar,可以自定义星星大小和间距
- 自定义view控件之TextView可以包含两种不同的字体风格
- 一个显示等级进度的控件,可以自定义等级值、颜色、游标等。
- 超好的纯js日期控件 可以自定义样式
- 自已开发的一个可以无限节点的自定义树型控件
- 自定义可以显示考勤状态的日历控件
- winform自定义日期控件,要求可以手动输入日期DatePicker
- 【Android自定义View实战】之自定义评价打分控件RatingBar,可以自定义星星大小和间距
- 【求助】要做这种可以缩放、旋转的控件该怎么弄?
- 自定义带箭头圆圈,自定义点击事件可以加减速,暂停继续,自动旋转
- android开发自定义View,可以自由拖动的控件
- 自定义View时,用到Paint Canvas的一些温故,自定义Loading控件(动画五,“六边形”的旋转跳跃)
- 关于自定义Tabbar控件,可以更改tabbar的样式和尺寸