Code example for RelativeLayout

Methods: getWidth, ofFloat, setAlpha

0
						showPanel(); 
					} else { 
						hidePanel(); 
					} 
				} else { 
					if (mTranslation <= 0.9 * mPanel.getWidth()) {
						hidePanel(); 
					} else { 
						showPanel(); 
					} 
				} 
 
				return true; 
			} 
 
			break; 
 
		case MotionEvent.ACTION_MOVE:
			if (mInSlide) {
				 
				float translation = event.getX() - mLastX;
				 
				mLastMoveOpen = translation >= 0;
				 
				mTranslation += translation;
				mAlpha = mTranslation / mPanel.getWidth();
 
				if (mTranslation > mPanel.getWidth()) {
					mTranslation = mPanel.getWidth();
					mAlpha = 1;
					mPanelShown = true;
				} 
 
				if (mTranslation < 0) {
					mTranslation = 0;
					mAlpha = 0;
					mPanelShown = false;
				} 
 
				mLastX = event.getX();
 
				mContent.setTranslationX(mTranslation);
				mPanel.setAlpha(mAlpha);
 
				return true; 
			} 
 
			break; 
		} 
 
		return super.onTouchEvent(event);
	} 
 
	public TabsScroller getTabsScroller() { 
		return mTabsScroller;
	} 
		 
	public void togglePanel() { 
		if (mPanelShown) {
			hidePanel(); 
		} else { 
			showPanel(); 
		} 
	} 
 
	public void showPanel() { 
		if (mAnimator != null) {
			mAnimator.end();
		} 
 
		mPanel.setAlpha(mAlpha);
 
		AnimatorSet animator = new AnimatorSet();		
 
		AnimatorSet.Builder b = animator.play(ObjectAnimator.ofFloat(mPanel, "alpha", 1));
 
		b.with(ObjectAnimator.ofFloat(mContent, "translationX", mPanel.getWidth()));
 
		animator.addListener(mShowListener);
 
		mAnimator = animator;
				 
		mAnimator.setDuration((long) (ANIMATION_DURATION * ((mPanel.getWidth() - mTranslation) / mPanel.getWidth())));
		mAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
 
		mAnimator.start();
	} 
 
	public void hidePanel() { 
		if (mAnimator != null) {
			mAnimator.end();
		} 
 
		mPanel.setAlpha(mAlpha);
 
		AnimatorSet animator = new AnimatorSet();
		AnimatorSet.Builder b = animator.play(ObjectAnimator.ofFloat(mPanel, "alpha", 0));
 
		b.with(ObjectAnimator.ofFloat(mContent, "translationX", 0));
 
		animator.addListener(mHideListener);
 
		mAnimator = animator;
 
		mAnimator.setDuration((long) (ANIMATION_DURATION * (mTranslation / mPanel.getWidth())));
		mAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
 
		mAnimator.start();
	}