基本信息
源码名称:android 移动PathMenu 菜单 例子源码下载
源码大小:1.57M
文件格式:.rar
开发语言:Java
更新时间:2015-04-01
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
pathmenu


public class PathMenuActivity extends Activity implements OnTouchListener {

	private boolean areButtonsShowing;
	private RelativeLayout composerButtonsWrapper;
	private ImageView composerButtonsShowHideButtonIcon;
	private RelativeLayout composerButtonsShowHideButton;
	private WebView wv;
	
	int lastX,lastY; 
	

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		MyAnimations.initOffset(PathMenuActivity.this);

		findViews();
		setListener();
		
		
		wv.loadUrl("http://mall.tymshop.com/index.aspx");
		wv.setWebViewClient(new WebViewClient());

		// 加号的动画
		composerButtonsShowHideButton.startAnimation(MyAnimations.getRotateAnimation(0, 360, 200));
		
		composerButtonsShowHideButton.setOnTouchListener(this);
	}
	
	//菜单拖动事件
	@Override
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		int ea=event.getAction();  
		DisplayMetrics dm=getResources().getDisplayMetrics();  
		   int screenWidth=dm.widthPixels;  
		   int screenHeight=dm.heightPixels-100;//需要减掉图片的高度  
		switch(ea){  
		case MotionEvent.ACTION_DOWN:             
		lastX=(int)event.getRawX();//获取触摸事件触摸位置的原始X坐标  
		lastY=(int)event.getRawY();             
		           case MotionEvent.ACTION_MOVE:
		             //event.getRawX();获得移动的位置
		int dx=(int)event.getRawX()-lastX;  
		int dy=(int)event.getRawY()-lastY;             
		int l=v.getLeft() dx;   
		int b=v.getBottom() dy;  
		int r=v.getRight() dx;  
		int t=v.getTop() dy;  
		 
		//下面判断移动是否超出屏幕  
		if(l<0){  
		l=0;      
		r=l v.getWidth();  
		}  
		if(t<0){  
		t=0;  
		b=t v.getHeight();  
		}  
		if(r>screenWidth){  
		r=screenWidth;  
		l=r-v.getWidth();  
		}  
		if(b>screenHeight){  
		b=screenHeight;  
		t=b-v.getHeight();  
		}  
		v.layout(l, t, r, b);  
		lastX=(int)event.getRawX();  
		lastY=(int)event.getRawY();
		
		/*v.setX(lastX);
 	   v.setY(lastY);*/
		v.postInvalidate();             
		break;  
		           case MotionEvent.ACTION_UP:
		             break;         
		           }

		return false;
	}
	

	private void findViews() {
		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);
		wv = (WebView) findViewById(R.id.webView123);
	}

	private void setListener() {
		// 给大按钮设置点击事件
		composerButtonsShowHideButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (!areButtonsShowing) {
					// 图标的动画
					MyAnimations.startAnimationsIn(composerButtonsWrapper, 300);
					// 加号的动画
					composerButtonsShowHideButtonIcon.startAnimation(MyAnimations.getRotateAnimation(0, 360, 300));
					
				} else {
					// 图标的动画
					MyAnimations.startAnimationsOut(composerButtonsWrapper, 300);
					// 加号的动画
					composerButtonsShowHideButtonIcon.startAnimation(MyAnimations.getRotateAnimation(360, 0, 300));
				}
				areButtonsShowing = !areButtonsShowing;
			}
		});

		// 给小图标设置点击事件
		for (int i = 0; i < composerButtonsWrapper.getChildCount(); i  ) {
			final ImageView smallIcon = (ImageView) composerButtonsWrapper.getChildAt(i);
			final int position = i;
			smallIcon.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View arg0) {
					// 这里写各个item的点击事件
					// 1.加号按钮缩小后消失 缩小的animation
					// 2.其他按钮缩小后消失 缩小的animation
					// 3.被点击按钮放大后消失 透明度渐变 放大渐变的animation
					if (smallIcon.getId()==R.id.composer_button_meichat) {
						Intent intent = new Intent(PathMenuActivity.this, ShowActivity.class);
						startActivity(intent);
					//	PathMenuActivity.this.finish();
					}
					if (smallIcon.getId()==R.id.composer_button_found) {
						Intent intent = new Intent(PathMenuActivity.this, ShowActivity.class);
						startActivity(intent);
					//	PathMenuActivity.this.finish();
					}
					if (smallIcon.getId()==R.id.composer_button_maillist) {
						Intent intent = new Intent(PathMenuActivity.this, ShowActivity.class);
						startActivity(intent);
					//	PathMenuActivity.this.finish();
					}
					if (smallIcon.getId()==R.id.composer_button_mysetting) {
						Intent intent = new Intent(PathMenuActivity.this, ShowActivity.class);
						startActivity(intent);
					//	PathMenuActivity.this.finish();
					}
					
					composerButtonsShowHideButtonIcon.startAnimation(MyAnimations.getRotateAnimation(-225, 0, 300));
					areButtonsShowing = !areButtonsShowing;
					smallIcon.startAnimation(MyAnimations.getMaxAnimation(400));
					for (int j = 0; j < composerButtonsWrapper.getChildCount(); j  ) {
						if (j != position) {
							final ImageView smallIcon = (ImageView) composerButtonsWrapper.getChildAt(j);
							smallIcon.startAnimation(MyAnimations.getMiniAnimation(300));
						}
					}
				}
			});
		}
	}
}