- 浏览: 5778770 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (890)
- WindowsPhone (0)
- android (88)
- android快速迭代 (17)
- android基础 (34)
- android进阶 (172)
- android高级 (0)
- android拾遗 (85)
- android动画&效果 (68)
- Material Design (13)
- LUA (5)
- j2me (32)
- jQuery (39)
- spring (26)
- hibernate (20)
- struts (26)
- tomcat (9)
- javascript+css+html (62)
- jsp+servlet+javabean (14)
- java (37)
- velocity+FCKeditor (13)
- linux+批处理 (9)
- mysql (19)
- MyEclipse (9)
- ajax (7)
- wap (8)
- j2ee+apache (24)
- 其他 (13)
- phonegap (35)
最新评论
-
Memories_NC:
本地lua脚本终于执行成功了,虽然不是通过redis
java中调用lua脚本语言1 -
ZHOU452840622:
大神://处理返回的接收状态 这个好像没有监听到 遇 ...
android 发送短信的两种方式 -
PXY:
拦截部分地址,怎么写的for(int i=0;i<lis ...
判断是否登录的拦截器SessionFilter -
maotou1988:
Android控件之带清空按钮(功能)的AutoComplet ...
自定义AutoCompleteTextView -
yangmaolinpl:
希望有表例子更好。。。,不过也看明白了。
浅谈onInterceptTouchEvent、onTouchEvent与onTouch
记得在eoe上有人发过,但代码质量不好。我重写了一下,抽成了控件。但没有经过各种控件的相容性测试,如果和其他控件的相容性不好,就直接在activity中写代码吧,应该差不多的。
我用的是平板,所以效果还行,不知道手机如何。
代码:
布局anim_buttons.xml:
用法:
网上又找到一个相同效果的。呵呵。
http://www.cnblogs.com/mudoot/archive/2012/01/19/path_composer_menu.html
最后一个:
可定制的圆形的浮动菜单Android控件:CircularFloatingActionMenu
https://github.com/oguzbilgener/CircularFloatingActionMenu
已更新。你看到的是老版本,相容性不好。
我用的是平板,所以效果还行,不知道手机如何。
代码:
package com.ql.view; import android.R.anim; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.animation.Animation; import android.view.animation.RotateAnimation; import android.view.animation.ScaleAnimation; import android.view.animation.TranslateAnimation; import android.view.animation.Animation.AnimationListener; import android.widget.Button; import android.widget.RelativeLayout; import com.ql.app.R; public class AnimButtons extends RelativeLayout{ private Context context; private int leftMargin=0,bottomMargin=0; private final int buttonWidth=58;//图片宽高 private final int r=180;//半径 private final int maxTimeSpent=200;//最长动画耗时 private final int minTimeSpent=80;//最短动画耗时 private int intervalTimeSpent;//每相邻2个的时间间隔 private Button[] btns; private Button btn_menu; private RelativeLayout.LayoutParams params; private boolean isOpen = false;//是否菜单打开状态 private float angle;//每个按钮之间的夹角 public AnimButtons(Context context) { super(context); // TODO Auto-generated constructor stub this.context=context; } public AnimButtons(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context=context; } @Override protected void onFinishInflate() { // TODO Auto-generated method stub super.onFinishInflate(); View view=LayoutInflater.from(context).inflate(R.layout.anim_buttons, this); initButtons(view); } private void initButtons(View view){ // TODO Auto-generated method stub //6个按钮,具体视情况而定 btns=new Button[6]; btns[0] = (Button) view.findViewById(R.id.btn_camera); btns[1] = (Button) view.findViewById(R.id.btn_with); btns[2] = (Button) view.findViewById(R.id.btn_place); btns[3] = (Button) view.findViewById(R.id.btn_music); btns[4] = (Button) view.findViewById(R.id.btn_thought); btns[5] = (Button) view.findViewById(R.id.btn_sleep); btn_menu = (Button) view.findViewById(R.id.btn_menu); leftMargin=((RelativeLayout.LayoutParams)(btn_menu.getLayoutParams())).leftMargin; bottomMargin=((RelativeLayout.LayoutParams)(btn_menu.getLayoutParams())).bottomMargin; for(int i=0;i<btns.length;i++){ btns[i].setLayoutParams(btn_menu.getLayoutParams());//初始化的时候按钮都重合 btns[i].setTag(String.valueOf(i)); btns[i].setOnClickListener(clickListener); } intervalTimeSpent=(maxTimeSpent-minTimeSpent)/btns.length;//20 angle=(float)Math.PI/(2*(btns.length-1)); } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { // TODO Auto-generated method stub super.onSizeChanged(w, h, oldw, oldh); final int bottomMargins=this.getMeasuredHeight()-buttonWidth-bottomMargin; // Log.i("tag", "bottomMargins====="+bottomMargins); btn_menu.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if(!isOpen){ isOpen = true; // btn_menu.startAnimation(animRotate(-45.0f, 0.5f, 0.45f)); for(int i=0;i<btns.length;i++){ float xLenth=(float)(r*Math.sin(i*angle)); float yLenth=(float)(r*Math.cos(i*angle)); // Log.i("tag", "xLenth======"+xLenth+",yLenth======"+yLenth); btns[i].startAnimation(animTranslate(xLenth, -yLenth, leftMargin+(int)xLenth, bottomMargins - (int)yLenth, btns[i], minTimeSpent+i*intervalTimeSpent)); } } else{ isOpen = false; // btn_menu.startAnimation(animRotate(90.0f, 0.5f, 0.45f)); for(int i=0;i<btns.length;i++){ float xLenth=(float)(r*Math.sin(i*angle)); float yLenth=(float)(r*Math.cos(i*angle)); // Log.i("tag", "xLenth======"+xLenth+",yLenth======"+yLenth); btns[i].startAnimation(animTranslate(-xLenth, yLenth, leftMargin, bottomMargins, btns[i], maxTimeSpent-i*intervalTimeSpent)); } } } }); } private Animation animScale(float toX, float toY){ // TODO Auto-generated method stub Animation animation = new ScaleAnimation(1.0f, toX, 1.0f, toY, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setInterpolator(context, anim.accelerate_decelerate_interpolator); animation.setDuration(400); animation.setFillAfter(false); return animation; } private Animation animRotate(float toDegrees, float pivotXValue, float pivotYValue){ // TODO Auto-generated method stub final Animation animation = new RotateAnimation(0, toDegrees, Animation.RELATIVE_TO_SELF, pivotXValue, Animation.RELATIVE_TO_SELF, pivotYValue); animation.setAnimationListener(new AnimationListener(){ @Override public void onAnimationStart(Animation animation){ // TODO Auto-generated method stub } @Override public void onAnimationRepeat(Animation animation){ // TODO Auto-generated method stub } @Override public void onAnimationEnd(Animation animation){ // TODO Auto-generated method stub animation.setFillAfter(true); } }); return animation; } private Animation animTranslate(float toX, float toY, final int lastX, final int lastY, final Button button, long durationMillis){ // TODO Auto-generated method stub Animation animation = new TranslateAnimation(0, toX, 0, toY); animation.setAnimationListener(new AnimationListener(){ @Override public void onAnimationStart(Animation animation){ // TODO Auto-generated method stub } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationEnd(Animation animation){ // TODO Auto-generated method stub params = new RelativeLayout.LayoutParams(0, 0); params.height = buttonWidth; params.width = buttonWidth; params.setMargins(lastX, lastY, 0, 0); button.setLayoutParams(params); button.clearAnimation(); } }); animation.setDuration(durationMillis); return animation; } View.OnClickListener clickListener=new View.OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub int selectedItem=Integer.parseInt((String)v.getTag()); for(int i=0;i<btns.length;i++){ if(i==selectedItem){ btns[i].startAnimation(animScale(2.0f, 2.0f)); }else{ btns[i].startAnimation(animScale(0.0f, 0.0f)); } } if(onButtonClickListener!=null){ onButtonClickListener.onButtonClick(v, selectedItem); } } }; public boolean isOpen(){ return isOpen; } private OnButtonClickListener onButtonClickListener; public interface OnButtonClickListener{ void onButtonClick(View v,int id); } public void setOnButtonClickListener(OnButtonClickListener onButtonClickListener){ this.onButtonClickListener=onButtonClickListener; } }
布局anim_buttons.xml:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFF" > <Button android:id="@+id/btn_sleep" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/composer_sleep" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" /> <Button android:id="@+id/btn_thought" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/composer_thought" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" /> <Button android:id="@+id/btn_music" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/composer_music" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" /> <Button android:id="@+id/btn_place" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/composer_place" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" /> <Button android:id="@+id/btn_with" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/composer_with" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" /> <Button android:id="@+id/btn_camera" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/composer_camera" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" /> <Button android:id="@+id/btn_menu" android:layout_width="58dip" android:layout_height="58dip" android:background="@drawable/friends_delete" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" android:layout_marginLeft="10dip" android:layout_marginBottom="10dip" /> </RelativeLayout>
用法:
public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); AnimButtons animButtons=(AnimButtons)findViewById(R.id.animButtons); animButtons.setOnButtonClickListener(new AnimButtons.OnButtonClickListener() { @Override public void onButtonClick(View v, int id) { // TODO Auto-generated method stub Log.i("tag", "id============="+id); } }); }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <!-- layout_width,layout_height最好是fill_parent参数 --> <com.ql.view.AnimButtons android:id="@+id/animButtons" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout>
网上又找到一个相同效果的。呵呵。
http://www.cnblogs.com/mudoot/archive/2012/01/19/path_composer_menu.html
最后一个:
可定制的圆形的浮动菜单Android控件:CircularFloatingActionMenu
https://github.com/oguzbilgener/CircularFloatingActionMenu
- PathButton.rar (165.2 KB)
- 描述: 写在Activity中的,已不推荐下载
- 下载次数: 201
- AnimButtons.rar (161.1 KB)
- 描述: 抽成控件,需要兼容性测试
- 下载次数: 596
- TestArcMenu.zip (1.4 MB)
- 描述: https://github.com/daCapricorn/ArcMenu
- 下载次数: 177
评论
8 楼
yang_杨炀
2014-02-21
好东西,LZ厉害
7 楼
aplixy
2013-12-29
封装的很好,三星s4上按钮太小了,网站不允许我发一些感谢你的话,唉
6 楼
lilongmin1109
2012-07-26
非常不错,支持
5 楼
ldci3gandroid
2012-03-07
太酷了 谢谢分享
4 楼
xinqiqi123
2011-12-12
顶下很牛叉
3 楼
hijovi
2011-12-12
path2.0... - -
2 楼
gundumw100
2011-12-09
tombeer 写道
支持作者,很好的效果。
已更新。你看到的是老版本,相容性不好。
1 楼
tombeer
2011-12-09
支持作者,很好的效果。
发表评论
-
ViewPager引导页根据滑动渐变背景色
2017-03-31 09:38 28151、主要依赖: compile'com.android.su ... -
Android 新推出基于物理的动画库SpringAnimation,完全诠释什么叫做弹簧效果
2017-03-30 10:38 2572Android 最近推出一个新的基于物理学的动画支持库,命名为 ... -
一个比较强大的提供各种形状的ImageView
2016-12-26 09:54 2933github上比较老的项目了,但是还是比较好用的。 各种形状总 ... -
PhotoView点击放大图片效果
2016-12-21 10:13 6051使用的PhotoView是这个版本的,比较小巧,很好用,比gi ... -
仿微信页面切换图标颜色渐变效果
2015-11-23 14:54 4418主要是提供一种思路,一般来书,类似效果无非就是在Canvas, ... -
把任意Drawable转换成基于progress填充的drawable
2015-11-11 16:29 2749把任意Drawable转换成基于progress填充的draw ... -
一个用来设置警示View 的呼吸式背景颜色的工具类BreathingViewHelper
2015-10-10 14:03 3037一个简单的小工具类,用来设置警示 View 的呼吸式背景颜色 ... -
单手操作图片控件 镜像、置顶、缩放、移动:StickerView
2015-10-08 11:21 3167单手操作图片控件 镜像、置顶、缩放、移动 impo ... -
图片浏览zoom效果
2015-10-08 11:05 1792不仅实现了Lollipop中打开新的activity 的zoo ... -
Android App状态栏变色:ColorfulStatusBar
2015-09-24 12:38 9909适用于版本大于等于19以上。 import android ... -
PathView实现炫酷SVG动画
2015-08-25 09:23 4403解析SVG,需要将一个androidsvg.jar包含进lib ... -
LinearLayout增加divider分割线
2015-08-13 14:58 11051在android3.0及后面的版本在LinearLayout里 ... -
Android换肤白天/夜间模式的框架
2015-07-29 15:36 2933Android换肤/夜间模式的Android框架,配合them ... -
使用ActivityOptions做Activity切换动画
2015-04-10 11:02 6576不知道大家有没有注意到startActivity(Intent ... -
一个不错的ArcMenu
2015-01-23 10:34 3904ArcMenu这种效果现在很多人都实现了 而且代码质量也 ... -
使用ScheduledExecutorService延时关闭一个全屏的对话框
2014-12-29 16:38 4371自定义style,设置全屏属性 <resources ... -
让View只显示下边框
2014-10-23 17:13 3965下面的代码是实现一个带边框的xml,很常见 <?xm ... -
让一张图片从模糊慢慢变清晰动画过程
2014-01-27 16:38 9250import java.io.IOExcepti ... -
ListView,GridView之LayoutAnimation特殊动画的实现
2013-05-24 11:23 34368LayoutAnimation干嘛用的?不知道的话网上搜一下。 ... -
食神摇摇中图片的晃动效果
2013-04-27 11:45 5453可以是这样子实现滴: btn_shake=(Image ...
相关推荐
android 扇形菜单(属性动画实现)
ios上的扇形弹出菜单,有动画效果,具体细节参考demo。
css3扇形菜单鼠标悬停css3旋转动画扇形打开菜单代码 css3扇形菜单鼠标悬停css3旋转动画扇形打开菜单代码 css3扇形菜单鼠标悬停css3旋转动画扇形打开菜单代码
css+javascript 实现扇形导航,有动画效果,从找到到收回,可以直接下载使用
扇形动画菜单,半圆形动画菜单实现,不过比较麻烦,建议使用属性动画实现
我们之前已经分享过很多CSS3菜单了,很多都比较实用,有部分CSS3菜单外观比较炫酷。今天要分享的这款CSS3菜单外观是扇形的,并且在鼠标滑过菜单时,扇形菜单项将会以动画的方式展开,并且支持多级下拉菜单。
网上开源的demo.仿path菜单,又叫卫星菜单什么的,封装好的view
仿path菜单,支持:左上;右上;右下;左下;中五个方向进行布局。利用三角函数计算位置,位置更加精准,弧度更加圆滑。中间布局时支持半圆形和圆形。
点击按钮,弹出子菜单选择二
CSS3科技感环形菜单动画特效
最近试着做了个Android 带有弹出收缩动画的扇形菜单,留个笔记记录一下。 效果如下 public class MainActivity extends AppCompatActivity implements View.OnClickListener { private ImageView imgPublish; ...
Gooey Effects 带粘性的扇形菜单.zip,不错的胶粘效果菜单。
Flutter的一个简单的动画径向菜单部件
昨日在一个前端网站上看见了一个老外写的纯用css3做的仿Path菜单,心里痒痒,于是也用jQuery写了一个,现在分享给大家
主要给大家介绍了利用纯CSS3实现扇形动画菜单(简化版)实例源码,文中给出了完整的示例源码,实现后的效果非常动感漂亮时尚,需要的朋友可以参考借鉴,下面来一起看看吧。
利用纯CSS3实现扇形动画菜单(简化版),实现后的效果非常动感漂亮时尚 样式不支持IE 纯css3样式引入页面即可,值得收藏与推荐
一款非常有个性的CSS3鼠标悬停3D图标菜单动画展开特效,鼠标悬停按钮时导航菜单项3D立体展开,鼠标离开则重新收缩起来。