public class SelectLayout extends LinearLayout { private AnimationSet mInAnime; private AnimationSet mOutAnime; private Animation mAlphaAnime; private View mCheckView; private View[] mViewArray; public SelectLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO 鑷姩鐢熸垚鐨勬瀯閫犲嚱鏁板瓨鏍? } public void iniSelectLayout(){ iniAnimation(); mViewArray=new View[getChildCount()]; for(int i=0;i<getChildCount();i++){ mViewArray[i]=getChildAt(i); if(i>0) mViewArray[i].startAnimation(mAlphaAnime); } mCheckView=mViewArray[0]; mCheckView.startAnimation(mInAnime); MyOnClickListener tmp=new MyOnClickListener(); for(View item:mViewArray) item.setOnClickListener(tmp); } private void iniAnimation(){ mInAnime=new AnimationSet(false); ScaleAnimation tmp=new ScaleAnimation(1, 1.2f, 1, 1.2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); tmp.setDuration(300); AlphaAnimation tmp2=new AlphaAnimation(0.7f, 1); tmp2.setDuration(300); mInAnime.addAnimation(tmp); mInAnime.addAnimation(tmp2); mInAnime.setFillAfter(true); tmp=new ScaleAnimation(1.2f, 1, 1.2f, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); tmp.setDuration(300); tmp2=new AlphaAnimation(1, 0.7f); tmp2.setDuration(300); mOutAnime=new AnimationSet(false); mOutAnime.addAnimation(tmp); mOutAnime.addAnimation(tmp2); mOutAnime.setFillAfter(true); mAlphaAnime=new AlphaAnimation(0.7f,0.7f); mAlphaAnime.setFillAfter(true); } public View getSelectView(){ return mCheckView; } private class MyOnClickListener implements OnClickListener{ @Override public void onClick(View v) { // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍? if(!v.equals(mCheckView)){ for(int i=0;i<mViewArray.length;i++){ if(!mViewArray[i].equals(v)&&!mViewArray[i].equals(mCheckView)) mViewArray[i].startAnimation(mAlphaAnime); } v.startAnimation(mInAnime); mCheckView.startAnimation(mOutAnime); mCheckView=v; } } }
继承自LinearLayout,在xml里当LinearLayout用就行了,调用iniSelectLayout后会有类似RadioGroup的功能,被选中的子View会放大,没被选中的是半透明。注意如果子View的背景是jpg的话会出现闪烁,png不会。
相关推荐
假如你需要RadioPreference或者一个带特殊功能的Preferece,当然你会选择了自定义一个Preference控件,但是会发现,自定义的Preference中Switch,CheckBox,Radio的动画效果没掉了,实在捉急。其实是因为android在...
假如你需要RadioPreference或者一个带特殊功能的Preferece,你可以选择了自定义一个Preference控件,不过你会发现,自定义的Preference中Switch,CheckBox,Radio的动画效果没掉了。其实是因为android在Preferece里面...
安卓源码包android 动画效果Android 烟花效果源码等21个合集: activity切换特效.rar Android Layout UI 首页加载过渡动画,星期变化动画.rar android 仿真翻页效果.rar Android 烟花效果源码.zip Android仿苹果的...
Boosted Android Tab Layout with custom animated indicators including "Dachshund" animation inspired by this. Sample Available Animated Indicators Indicator Example Custom behavior ...
主要介绍了Android自定义水波纹动画Layout的实例代码,非常不错,具有参考借鉴价值,需要的朋友可以参考下
A custom layout that can easily switch different states(like empty,error,progress,content) with animations. An example usage can be found here lufficc/iShuiHui Usage Add the dependencies to your ...
通过自定义android高级UI实现了一种类似小鱼游泳的炫酷效果,自定义drawable、自定义layout、属性动画的使用、点击事件的处理、水波纹效果、贝塞尔曲线的使用等等,实现的小鱼不仅会动,还能根据鼠标点击的位置进行...
http://blog.csdn.net/qq970259858/article/details/51661407
Android 自定义View实现抽屉效果 说明 这个自定义View,没有处理好多点触摸问题 View跟着手指移动,没有采用传统的scrollBy方法,而是通过不停地重新布局子View的方式,来使得子View产生滚动效果menuView.layout...
本文实例为大家分享了Android自定义View实现波浪动画的具体代码,供大家参考,具体内容如下 效果演示 代码调用与实现效果 xml中调用 <developer android:layout_width=match_parent android:layout_height=match_...
先自定义一个View,继承自LinearLayout,在Layout中,添加布局控件 /** * Created by xiedong on 2017/3/7. */ public class Loading_view extends LinearLayout { private Context mContext; private ...
android 仿ppt进入动画效果合集, 百叶窗效果,擦除效果,盒状效果,阶梯效果,菱形效果,轮子效果,劈裂效果,棋盘效果, 切入效果,扇形展开效果,十字扩展效果,随机线条效果,向内溶解效果,圆形扩展效果, 适用...
The Cult will provide a new layout for your Toolbar. This allow you to use with a custom SearchView with animation and more. This library should work on API 14. Usage You can use this library like a ...
本文实例讲述了Android编程ProgressBar自定义样式之动画模式实现方法。分享给大家供大家参考,具体如下: 忘记在哪里看到的那位仁兄写的,就是通过用动画效果来实现的,现在顺便也把他写出来,希望那位仁兄不要见怪...
自定义并准备好为 React Native 部分自定义动画布局。 安装 添加依赖: React原生: npm i react - native - animation - layout 对等依赖 重要的! 你需要安装它们。 "react": ">= 16.x.x", "react-native": ">...
本文介绍了Android自定义控件之翻转按钮的示例代码,分享给大家,具体如下: 先看一下效果 一.先定义控件的基本结构 这里我们定义一个容器,所以是在ViewGroup的基础上扩展。 简单起见,直接使用扩展自ViewGroup...
使用自定义Animation,实现View的左右摇摆效果,如图所示: 代码很简单,直接上源码 activity_maini.xml布局文件: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=...
自定义卡片移除动画 支持加载更多 使用方式 gradle dependency // 1. Add it in your root build.gradle at the end of repositories: allprojects { repositories { ... maven { url 'https://jitpack.io' } }...
android_maskable_layout-master,自定义可屏蔽的布局,博客附件,效果请查看博客相对应项目。