android.view.animation.Animation#RELATIVE_TO_PARENT源码实例Demo

下面列出了android.view.animation.Animation#RELATIVE_TO_PARENT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MaterialScrollBar   文件: MaterialScrollBar.java
private void generalSetup() {
    recyclerView.setVerticalScrollBarEnabled(false); // disable any existing scrollbars
    recyclerView.addOnScrollListener(new ScrollListener()); // lets us read when the recyclerView scrolls

    setTouchIntercept(); // catches touches on the bar

    identifySwipeRefreshParents();

    checkCustomScrolling();

    for(int i = 0; i < onAttach.size(); i++) {
        onAttach.get(i).run();
    }

    //Hides the view
    TranslateAnimation anim = new TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_SELF, rtl ? -getHideRatio() : getHideRatio(),
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    anim.setDuration(0);
    anim.setFillAfter(true);
    hidden = true;
    startAnimation(anim);
}
 
源代码2 项目: imsdk-android   文件: CustomCaptureActvity.java
private void initCamera()
{
    autoFocusHandler = new Handler();
    mCameraManager = new CameraManager(this);
    try {
        mCameraManager.openDriver();
    } catch (Exception e) {
        LogUtil.e(TAG,"ERROR",e);
        finish();
    }

    mCamera = mCameraManager.getCamera();
    mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
    scanPreview.addView(mPreview);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.85f);
    animation.setDuration(3000);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.REVERSE);
    scanLine.startAnimation(animation);
}
 
源代码3 项目: RecyclerWheelPicker   文件: WheelPicker.java
public void doEnterAnim(final View contentView, long animDuration) {
    if (builder.gravity == Gravity.BOTTOM) {
        ValueAnimator enterAnimator = ValueAnimator.ofFloat(contentView.getHeight(), 0);
        enterAnimator.setDuration(animDuration);
        enterAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float value = (float) animation.getAnimatedValue();
                contentView.setTranslationY(value);
            }
        });
        enterAnimator.start();
    } else {
        ScaleAnimation scaleAnimation = new ScaleAnimation(0F, 1.0F, 0F, 1.0F,
                Animation.RELATIVE_TO_PARENT, 0.5F, Animation.RELATIVE_TO_PARENT, 0.5F);
        scaleAnimation.setDuration(animDuration);
        scaleAnimation.setFillAfter(true);
        contentView.startAnimation(scaleAnimation);
    }
}
 
源代码4 项目: RecyclerWheelPicker   文件: WheelPicker.java
public void doExitAnim(final View contentView, long animDuration) {
    if (builder.gravity == Gravity.BOTTOM) {
        ValueAnimator exitAnimator = ValueAnimator.ofFloat(0, contentView.getHeight());
        exitAnimator.setDuration(animDuration);
        exitAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float value = (float) animation.getAnimatedValue();
                contentView.setTranslationY(value);
            }
        });
        exitAnimator.start();
    } else {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.0F, 0.0F, 1.0F, 0.0F,
                Animation.RELATIVE_TO_PARENT, 0.5F, Animation.RELATIVE_TO_PARENT, 0.5F);
        scaleAnimation.setDuration(animDuration);
        scaleAnimation.setFillAfter(true);
        contentView.startAnimation(scaleAnimation);
    }
}
 
源代码5 项目: Paginize   文件: SquashPageAnimator.java
private void initAnimations() {
  DecelerateInterpolator interpolator = new DecelerateInterpolator(3.0f);
  mExpandInFromRightAnimation = new ScaleAnimation(0, 1, 1, 1,
      Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
  mExpandInFromRightAnimation.setInterpolator(interpolator);
  mExpandInFromRightAnimation.setDuration(ANIMATION_DURATION);

  mShrinkOutFromRightAnimation = new ScaleAnimation(1, 0, 1, 1,
      Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0);
  mShrinkOutFromRightAnimation.setInterpolator(interpolator);
  mShrinkOutFromRightAnimation.setDuration(ANIMATION_DURATION);

  mExpanndInFromLeftAnimation = new ScaleAnimation(0, 1, 1, 1,
      Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0);
  mExpanndInFromLeftAnimation.setInterpolator(interpolator);
  mExpanndInFromLeftAnimation.setDuration(ANIMATION_DURATION);

  mShrinkOutFromLeftAnimation = new ScaleAnimation(1, 0, 1, 1,
      Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
  mShrinkOutFromLeftAnimation.setInterpolator(interpolator);
  mShrinkOutFromLeftAnimation.setDuration(ANIMATION_DURATION);
}
 
源代码6 项目: Paginize   文件: SquashPageAnimator.java
private void initAnimations() {
  DecelerateInterpolator interpolator = new DecelerateInterpolator(3.0f);
  mExpandInFromRightAnimation = new ScaleAnimation(0, 1, 1, 1, Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
  mExpandInFromRightAnimation.setInterpolator(interpolator);
  mExpandInFromRightAnimation.setDuration(ANIMATION_DURATION);

  mShrinkOutFromRightAnimation = new ScaleAnimation(1, 0, 1, 1, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0);
  mShrinkOutFromRightAnimation.setInterpolator(interpolator);
  mShrinkOutFromRightAnimation.setDuration(ANIMATION_DURATION);

  mExpanndInFromLeftAnimation = new ScaleAnimation(0, 1, 1, 1, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0);
  mExpanndInFromLeftAnimation.setInterpolator(interpolator);
  mExpanndInFromLeftAnimation.setDuration(ANIMATION_DURATION);

  mShrinkOutFromLeftAnimation = new ScaleAnimation(1, 0, 1, 1, Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
  mShrinkOutFromLeftAnimation.setInterpolator(interpolator);
  mShrinkOutFromLeftAnimation.setDuration(ANIMATION_DURATION);
}
 
源代码7 项目: mobile-sdk-android   文件: MoveIn.java
private void setInAnimation(float[] direction, Interpolator interpolator, long duration){
    inAnimation = new TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, direction[0], Animation.RELATIVE_TO_PARENT, direction[1],
            Animation.RELATIVE_TO_PARENT, direction[2], Animation.RELATIVE_TO_PARENT, direction[3]
    );
    inAnimation.setInterpolator(interpolator);
    inAnimation.setDuration(duration);
}
 
源代码8 项目: NetCloud_android   文件: WindowStack.java
public WindowStack(Context context){
    mStack = new Stack<>();
    mRoot = new StackView(context);
    mRoot.setBackgroundColor(Color.TRANSPARENT);

    mAnimIn = new TranslateAnimation(Animation.RELATIVE_TO_PARENT,1,Animation.RELATIVE_TO_PARENT,0,
            Animation.RELATIVE_TO_PARENT,0,Animation.RELATIVE_TO_PARENT,0);
    mAnimIn.setDuration(300);
    mAnimOut = new TranslateAnimation(Animation.RELATIVE_TO_PARENT,0,Animation.RELATIVE_TO_PARENT,1,
            Animation.RELATIVE_TO_PARENT,0,Animation.RELATIVE_TO_PARENT,0);
    mAnimOut.setDuration(300);

    mSwipeDetector = new SwipeDectector(this);
}
 
源代码9 项目: RearrangeableLayout   文件: RearrangeableLayout.java
private void init(Context context, AttributeSet attrs) {
    mStartTouch = null;
    mSelectedChild = null;
    mContainer = new SparseArray<Parcelable>(5);
    mListener = null;
    mChildStartRect = null;
    mChildEndRect = null;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RearrangeableLayout);
    float strokeWidth = a.getDimension(R.styleable.RearrangeableLayout_outlineWidth, 2.0f);
    int color = a.getColor(R.styleable.RearrangeableLayout_outlineColor, Color.GRAY);
    float alpha = a.getFloat(R.styleable.RearrangeableLayout_selectionAlpha, 0.5f);
    mSelectionZoom = a.getFloat(R.styleable.RearrangeableLayout_selectionZoom, 1.2f);
    a.recycle();

    float filter[] = new float[] {
            1f, 0f, 0f, 0f, 0f,
            0f, 1f, 0f, 0f, 0f,
            0f, 0f, 1f, 0f, 0f,
            0f, 0f, 0f, alpha, 0f
    };
    ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(new ColorMatrix(filter));

    mOutlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setStrokeWidth(strokeWidth);
    mOutlinePaint.setColor(color);
    mOutlinePaint.setColorFilter(colorFilter);

    mSelectionPaint = new Paint();
    mSelectionPaint.setColorFilter(colorFilter);

    Animation trans = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0,
            Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
    trans.setDuration(500);
    trans.setInterpolator(new AccelerateInterpolator(1.0f));

    LayoutAnimationController c = new LayoutAnimationController(trans, 0.25f);
    setLayoutAnimation(c);
}
 
源代码10 项目: MaterialScrollBar   文件: TouchScrollBar.java
/**
 * Provides the ability to programmatically alter whether the scrollbar
 * should hide after a period of inactivity or not.
 * @param hide sets whether the bar should hide or not.
 *
 *             This method is experimental
 */
public TouchScrollBar setAutoHide(Boolean hide) {
    if(!hide) {
        TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
                Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
        anim.setFillAfter(true);
        startAnimation(anim);
    }
    //This is not obeyed. If you print `hide` outside of this method it disagrees with what is
    //set here. I have no idea wtf is going on so if anyone could figure that out that'd be
    //great.
    this.hide = hide;
    return this;
}
 
源代码11 项目: financisto   文件: PinView.java
private Animation outToLeftAnimation() {
	Animation outtoLeft = new TranslateAnimation(
			Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, -1.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f);
	outtoLeft.setDuration(300);
	outtoLeft.setInterpolator(new AccelerateInterpolator());
	return outtoLeft;
}
 
源代码12 项目: coursera-android   文件: ViewFlipperTestActivity.java
private Animation inFromRightAnimation() {
	Animation inFromRight = new TranslateAnimation(
			Animation.RELATIVE_TO_PARENT, +1.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f);
	inFromRight.setDuration(500);
	inFromRight.setInterpolator(new LinearInterpolator());
	return inFromRight;
}
 
源代码13 项目: Trivia-Knowledge   文件: Category.java
private Animation inFromLeftAnimation() {
    Animation inFromLeft = new TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, -1.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    inFromLeft.setDuration(600);
    inFromLeft.setInterpolator(new AccelerateInterpolator());
    return inFromLeft;
}
 
源代码14 项目: proteus   文件: AnimationUtils.java
/**
 * Size descriptions can appear in three forms:
 * <ol>
 * <li>An absolute size. This is represented by a number.</li>
 * <li>A size relative to the size of the object being animated. This
 * is represented by a number followed by "%".</li> *
 * <li>A size relative to the size of the parent of object being
 * animated. This is represented by a number followed by "%p".</li>
 * </ol>
 *
 * @param value The Json value to parse
 * @return The parsed version of the description
 */
static Description parseValue(Value value) {
  Description d = new Description();
  d.type = Animation.ABSOLUTE;
  d.value = 0;
  if (value != null && value.isPrimitive()) {
    if (value.getAsPrimitive().isNumber()) {
      d.type = Animation.ABSOLUTE;
      d.value = value.getAsPrimitive().getAsFloat();
    } else {
      String stringValue = value.getAsPrimitive().getAsString();
      if (stringValue.endsWith(PERCENT_SELF)) {
        stringValue = stringValue.substring(0, stringValue.length() - PERCENT_SELF.length());
        d.value = Float.parseFloat(stringValue) / 100;
        d.type = Animation.RELATIVE_TO_SELF;
      } else if (stringValue.endsWith(PERCENT_RELATIVE_PARENT)) {
        stringValue = stringValue.substring(0, stringValue.length() - PERCENT_RELATIVE_PARENT.length());
        d.value = Float.parseFloat(stringValue) / 100;
        d.type = Animation.RELATIVE_TO_PARENT;
      } else {
        d.type = Animation.ABSOLUTE;
        d.value = value.getAsPrimitive().getAsFloat();
      }
    }
  }

  return d;
}
 
源代码15 项目: mobile-sdk-android   文件: Push.java
private Animation getAnimation(float[] direction, Interpolator interpolator, long duration){
    Animation animation = new TranslateAnimation(
                    Animation.RELATIVE_TO_PARENT, direction[0], Animation.RELATIVE_TO_PARENT, direction[1],
                    Animation.RELATIVE_TO_PARENT, direction[2], Animation.RELATIVE_TO_PARENT, direction[3]
            );
    animation.setInterpolator(interpolator);
    animation.setDuration(duration);
    return animation;
}
 
源代码16 项目: coursera-android   文件: ViewFlipperTestActivity.java
private Animation inFromRightAnimation() {
	Animation inFromRight = new TranslateAnimation(
			Animation.RELATIVE_TO_PARENT, +1.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f);
	inFromRight.setDuration(500);
	inFromRight.setInterpolator(new LinearInterpolator());
	return inFromRight;
}
 
源代码17 项目: appinventor-extensions   文件: AnimationUtil.java
private static void ApplyHorizontalScrollAnimation(View view, boolean left, int speed) {
  float sign = left ? 1f : -1f;
  AnimationSet animationSet = new AnimationSet(true);
  animationSet.setRepeatCount(Animation.INFINITE);
  animationSet.setRepeatMode(Animation.RESTART);

  TranslateAnimation move = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, sign * 0.70f,
      Animation.RELATIVE_TO_PARENT, sign * -0.70f, Animation.RELATIVE_TO_PARENT, 0,
      Animation.RELATIVE_TO_PARENT, 0);
  move.setStartOffset(0);
  move.setDuration(speed);
  move.setFillAfter(true);
  animationSet.addAnimation(move);
  view.startAnimation(animationSet);
}
 
源代码18 项目: appcan-android   文件: EBrowserWidget.java
public void goMySpace(View view) {
    addView(view);
    TranslateAnimation anim = new TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 1.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f);
    anim.setDuration(250);
    DecelerateInterpolator di = new DecelerateInterpolator();
    anim.setInterpolator(di);
    view.startAnimation(anim);
    mBroWindow.setVisibility(GONE);
}
 
源代码19 项目: FamilyChat   文件: QrCodeScanActivity.java
protected void initUI()
{
    //全屏设置
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
    {
        View statusBar = findViewById(R.id.view_qrcode_actionbar_status);
        statusBar.setVisibility(View.VISIBLE);
        ViewGroup.LayoutParams layoutParams = statusBar.getLayoutParams();
        layoutParams.height = OtherUtils.getStatusBarHeight(this);
        statusBar.setLayoutParams(layoutParams);
    }

    //闪光灯
    mImgLight = (ImageView) findViewById(R.id.img_qrcode_light);

    mScanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    mScanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    mScanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    mScanLine = (ImageView) findViewById(R.id.capture_scan_line);
    //设置阴影
    View shadowTop = findViewById(R.id.capture_mask_top);
    View shadowBottom = findViewById(R.id.capture_mask_bottom);
    View shadowLeft = findViewById(R.id.capture_mask_left);
    View shadowRight = findViewById(R.id.capture_mask_right);
    shadowTop.setAlpha(0.5f);
    shadowBottom.setAlpha(0.5f);
    shadowLeft.setAlpha(0.5f);
    shadowRight.setAlpha(0.5f);

    mInactivityTimer = new InactivityTimer(this);
    mBeepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
            .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.85f);
    animation.setDuration(2500);
    animation.setRepeatCount(-1);
    animation.setInterpolator(new AccelerateDecelerateInterpolator(QrCodeScanActivity.this, null));
    animation.setRepeatMode(Animation.RESTART);
    mScanLine.startAnimation(animation);

    findViewById(R.id.ll_qrcode_actionbar_left_back).setOnClickListener(this);
    mImgLight.setOnClickListener(this);
}
 
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	/**
	 * 设置为竖屏
	 */
	if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
	}

	Window window = getWindow();
	window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	setContentView(R.layout.activity_gos_capture);

	scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
	scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
	scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
	scanLine = (ImageView) findViewById(R.id.capture_scan_line);

	inactivityTimer = new InactivityTimer(this);

	TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
			Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT,
			0.0f);
	animation.setDuration(4500);
	animation.setRepeatCount(-1);
	animation.setRepeatMode(Animation.RESTART);
	scanLine.startAnimation(animation);

	btnCancel = (Button) findViewById(R.id.btn_cancel);
	ivReturn = (ImageView) findViewById(R.id.iv_return);
	OnClickListener myClick = new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			CaptureActivity.this.finish();
		}
	};
	btnCancel.setOnClickListener(myClick);
	ivReturn.setOnClickListener(myClick);
}