先上效果图

主界面布局文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/default_homebg"> <RelativeLayout
android:id="@+id/composer_buttons_wrapper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:clipChildren="false"
android:clipToPadding="false" > <ImageButton
android:id="@+id/composer_button_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="142dp"
android:layout_marginRight="10.667dp"
android:background="@drawable/composer_camera"
android:visibility="gone" /> <ImageButton
android:id="@+id/composer_button_people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="135.333dp"
android:layout_marginRight="52dp"
android:background="@drawable/composer_with"
android:visibility="gone" /> <ImageButton
android:id="@+id/composer_button_place"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="116.666dp"
android:layout_marginRight="89.33333333333333dp"
android:background="@drawable/composer_place"
android:visibility="gone" /> <ImageButton
android:id="@+id/composer_button_music"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="87.33333333333333dp"
android:layout_marginRight="118.6666666666667dp"
android:background="@drawable/composer_music"
android:visibility="gone" /> <ImageButton
android:id="@+id/composer_button_thought"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="50dp"
android:layout_marginRight="137.3333333333333dp"
android:background="@drawable/composer_thought"
android:visibility="gone" /> <ImageButton
android:id="@+id/composer_button_sleep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="8.666666666666667dp"
android:layout_marginRight="144dp"
android:background="@drawable/composer_sleep"
android:visibility="gone" />
</RelativeLayout> <RelativeLayout
android:id="@+id/composer_buttons_show_hide_button"
android:layout_width="60dp"
android:layout_height="57.33333333333333dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/composer_button" > <ImageView
android:id="@+id/composer_buttons_show_hide_button_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/composer_icn_plus" />
</RelativeLayout>
</RelativeLayout>

两个动画文件(in和out)

<?xml version="1.0" encoding="UTF-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:duration="150"
android:fromDegrees="0.0"
android:toDegrees="-225.0"
android:pivotX="50.0%"
android:pivotY="50.0%"
android:fillAfter="true"
android:fillEnabled="true"
/>
<?xml version="1.0" encoding="UTF-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:duration="150"
android:fromDegrees="-225.0"
android:toDegrees="0.0"
android:pivotX="50.0%"
android:pivotY="50.0%"
android:fillAfter="true"
android:fillEnabled="true"
/>

动画类文件

import android.content.Context;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.animation.Animation;
import android.view.animation.AnticipateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageButton; public class MyAnimations{ private static int xOffset = 15;
private static int yOffset = -13; public static void initOffset(Context context){//鐢卞竷灞�枃浠�
xOffset = (int) (10.667 *context.getResources().getDisplayMetrics().density);
yOffset = -(int) (8.667 *context.getResources().getDisplayMetrics().density);
} public static Animation getRotateAnimation(float fromDegrees ,float toDegrees,int durationMillis){
RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(durationMillis);
rotate.setFillAfter(true);
return rotate;
} public static void startAnimationsIn(ViewGroup viewgroup,int durationMillis) {
for (int i = 0; i < viewgroup.getChildCount(); i++) {
ImageButton inoutimagebutton = (ImageButton) viewgroup
.getChildAt(i);
inoutimagebutton.setVisibility(0);
MarginLayoutParams mlp = (MarginLayoutParams) inoutimagebutton.getLayoutParams();
Animation animation = new TranslateAnimation(mlp.rightMargin-xOffset,0F,yOffset + mlp.bottomMargin, 0F); animation.setFillAfter(true);animation.setDuration(durationMillis);
animation.setStartOffset((i * 100)
/ (-1 + viewgroup.getChildCount()));
animation.setInterpolator(new OvershootInterpolator(2F));
inoutimagebutton.startAnimation(animation); }
}
public static void startAnimationsOut(ViewGroup viewgroup,int durationMillis) {
for (int i = 0; i < viewgroup.getChildCount(); i++) {
final ImageButton inoutimagebutton = (ImageButton) viewgroup
.getChildAt(i);
MarginLayoutParams mlp = (MarginLayoutParams) inoutimagebutton.getLayoutParams();
Animation animation = new TranslateAnimation(0F,mlp.rightMargin-xOffset, 0F,yOffset + mlp.bottomMargin); animation.setFillAfter(true);animation.setDuration(durationMillis);
animation.setStartOffset(((viewgroup.getChildCount()-i) * 100)
/ (-1 + viewgroup.getChildCount()));//椤哄簭鍊掍竴涓嬫瘮杈冭垝鏈�
animation.setInterpolator(new AnticipateInterpolator(2F));
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {}
@Override
public void onAnimationRepeat(Animation arg0) {}
@Override
public void onAnimationEnd(Animation arg0) {
// TODO Auto-generated method stub
inoutimagebutton.setVisibility(8);
}
});
inoutimagebutton.startAnimation(animation);
} } }

最后是主界面activity文件

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout; public class PathMenuActivity extends Activity {
/** Called when the activity is first created. */ private boolean areButtonsShowing;
private RelativeLayout composerButtonsWrapper;
private ImageView composerButtonsShowHideButtonIcon;
private RelativeLayout composerButtonsShowHideButton; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); MyAnimations.initOffset(PathMenuActivity.this);
composerButtonsWrapper = (RelativeLayout) findViewById(R.id.composer_buttons_wrapper);
composerButtonsShowHideButton = (RelativeLayout) findViewById(R.id.composer_buttons_show_hide_button);
composerButtonsShowHideButtonIcon = (ImageView) findViewById(R.id.composer_buttons_show_hide_button_icon); composerButtonsShowHideButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!areButtonsShowing) {
MyAnimations.startAnimationsIn(composerButtonsWrapper, 300);
composerButtonsShowHideButtonIcon
.startAnimation(MyAnimations.getRotateAnimation(0,
-270, 300));
} else {
MyAnimations
.startAnimationsOut(composerButtonsWrapper, 300);
composerButtonsShowHideButtonIcon
.startAnimation(MyAnimations.getRotateAnimation(
-270, 0, 300));
}
areButtonsShowing = !areButtonsShowing;
}
});
for (int i = 0; i < composerButtonsWrapper.getChildCount(); i++) {
composerButtonsWrapper.getChildAt(i).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View arg0) {
}
});
} composerButtonsShowHideButton.startAnimation(MyAnimations
.getRotateAnimation(0, 360, 200)); } }

PATH menu的更多相关文章

  1. 【转】GitHub 排名前 100 的安卓、iOS项目简介

    GitHub Android Libraries Top 100 简介 排名完全是根据 GitHub 搜索 Java 语言选择 (Best Match) 得到的结果, 然后过滤了跟 Android 不 ...

  2. GitHub iOS-Top 100 简介

    GitHub排名前100的iOS第三方汇总简介,方便开发者选择适合的第三方框架. 项目名称 项目信息 1. AFNetworking 作者是 NSHipster 的博主, iOS 开发界的大神级人物, ...

  3. GitHub 上排名前 100 的 Objective-C 项目简介

    主要对当前 GitHub 排名前 100 的项目做一个简单的简介, 方便初学者快速了解到当前 Objective-C 在 GitHub 的情况.   项目名称 项目信息 1. AFNetworking ...

  4. GitHub Top 100 的项目(iOS)

    主要对当前 GitHub 排名前 100 的项目做一个简单的简介, 方便初学者快速了解到当前 Objective-C 在 GitHub 的情况. Android 版本的在此: https://gith ...

  5. 2016年GitHub 排名前 100 的安卓、iOS项目简介(收藏)

    排名完全是根据 GitHub 搜索 Java 语言选择 (Best Match) 得到的结果, 然后过滤了跟 Android 不相关的项目, 所以排名并不具备任何官方效力, 仅供参考学习, 方便初学者 ...

  6. 观看github前100开源项目的读后感

    文章来自:http://www.oschina.net/news/61416/github-top-100-objective-c-projects?from=20150412 ReactiveCoc ...

  7. GitHub上排名前100的iOS开源库介绍(来自github)

    主要对当前 GitHub 排名前 100 的项目做一个简单的简介,方便初学者快速了解到当前 Objective-C 在 GitHub 的情况. 若有任何疑问可通过微博@李锦发联系我 项目名称 项目信息 ...

  8. [转]Unity: make your lists functional with ReorderableList

    原文地址:http://va.lent.in/unity-make-your-lists-functional-with-reorderablelist/ This article is reprod ...

  9. drupal里面的ajax最粗浅的理解-流程

    1,  form里面的ajax所在地表单元素有一个事件,激发system/ajax,相应的有ajax_form_callback(), 会把被改变的元素值传到form_state[values]中, ...

随机推荐

  1. WPF 截屏软件开发

    最近由于工程需要开始研发基于Windows的自动录屏软件,很多细节很多功能需要处理,毕竟一个完美的录屏软件不是你随随便便就可以写出来的.首先参考了大部分的录屏软件,在研发的过程中遇到了很多的问题:比如 ...

  2. Redis基础学习(一)—Redis的安装

    一.Redis的安装 1.在Linux环境下安装gcc环境 yum install gcc-c++   2.解压缩Redis源码包 tar -zxf redis-3.0.0.tar.gz   3.编译 ...

  3. vim中文帮助文档安装

    vim自带的帮助手册是英文的, 对平时编程的人来说没有多大阅读困难,在何况还有"星级译王"呢, 但是我猜和我一样连英语四级都愁的大有人,可偏偏就有一帮好心人人将其翻译成了中文, 可 ...

  4. Ecplise 中 加载JDBC 连接 Mysql 数据库读取数据

    准备工作 首先下载 JDBC 驱动,下载地址https://www.mysql.com/products/connector/ 将压缩包解压得到文件 mysql-connector-java-5.1. ...

  5. 【学而思】利用shouldComponentUpdate钩子函数优化react性能以及引入immutable库的必要性

    凡是参阅过react官方英文文档的童鞋大体上都能知道对于一个组件来说,其state的改变(调用this.setState()方法)以及从父组件接受的props发生变化时,会导致组件重渲染,正所谓&qu ...

  6. ios UIImagePickerController简单说明

    首先,VC中添加#import <MobileCoreServices/MobileCoreServices.h> 使用(NSString *) kUTTypeImage定义在其中 判断是 ...

  7. html 选择器之属性选择器

    属性选择器的主要作用个人的理解就是对带有指定属性的元素设置css样式. 使用css3的属性选择器,可以指定元素的某个属性,也可以指定某个属性和这个属性所对应的值. css3的属性选择器主要包括下面几种 ...

  8. Linux常用命令快查

    一.读取配置文件中某一个变量的值 假如有一个配置文件dubbo.properties,需要读取dubbo.application.name的值: dubbo.application.name=book ...

  9. WinForm中控件位置不随窗体大小的变化而改变

    背景:在窗体开发中使控件的位置不随窗体的大小改变而变化的问题?这是一个同事在开发时遇到的问题,在思考试错之后,写出如下代码. 声明成员: Point m_InitLocation; Size m_In ...

  10. "fatal: protocol error: bad line length character: No This"

    git clone 远程地址时候出现 "fatal: protocol error: bad line length character: No This" 错误 在stackov ...