android.view.animation.RotateAnimation#RELATIVE_TO_SELF源码实例Demo

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

源代码1 项目: wallpaper   文件: PullToRefreshView.java
/**
 * init
 * 
 * @description
 * @param context
 *            hylin 2012-7-26上午10:08:33
 */
private void init() {
	// Load all of the animations we need in code rather than through XML
	mFlipAnimation = new RotateAnimation(0, -180,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mFlipAnimation.setInterpolator(new LinearInterpolator());
	mFlipAnimation.setDuration(250);
	mFlipAnimation.setFillAfter(true);
	mReverseFlipAnimation = new RotateAnimation(-180, 0,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
	mReverseFlipAnimation.setDuration(250);
	mReverseFlipAnimation.setFillAfter(true);

	mInflater = LayoutInflater.from(getContext());
	// header view 在此添加,保证是第一个添加到linearlayout的最上端
	addHeaderView();
}
 
源代码2 项目: Huochexing12306   文件: PullToRefreshView.java
/**
 * init
 * 
 * @description
 * @param context
 *            hylin 2012-7-26上午10:08:33
 */
private void init() {
	// Load all of the animations we need in code rather than through XML
	mFlipAnimation = new RotateAnimation(0, -180,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mFlipAnimation.setInterpolator(new LinearInterpolator());
	mFlipAnimation.setDuration(250);
	mFlipAnimation.setFillAfter(true);
	mReverseFlipAnimation = new RotateAnimation(-180, 0,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
	mReverseFlipAnimation.setDuration(250);
	mReverseFlipAnimation.setFillAfter(true);

	mInflater = LayoutInflater.from(getContext());
	// header view 在此添加,保证是第一个添加到linearlayout的最上端
	addHeaderView();
}
 
源代码3 项目: UltimateAndroid   文件: PullToRefreshView.java
/**
 * init
 *
 * @param
 * @description
 */
private void init() {
    // Load all of the animations we need in code rather than through XML
    mFlipAnimation = new RotateAnimation(0, -180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
    mReverseFlipAnimation = new RotateAnimation(-180, 0,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(250);
    mReverseFlipAnimation.setFillAfter(true);

    mInflater = LayoutInflater.from(getContext());
    // header view 在此添加,保证是第一个添加到linearlayout的最上端
    addHeaderView();
}
 
@Override
public void onExpansionToggled(boolean expanded) {
    super.onExpansionToggled(expanded);
    if (!HONEYCOMB_AND_ABOVE) {
        return;
    }

    RotateAnimation rotateAnimation = new RotateAnimation(ROTATED_POSITION,
            INITIAL_POSITION,
            RotateAnimation.RELATIVE_TO_SELF, PIVOT_VALUE,
            RotateAnimation.RELATIVE_TO_SELF, PIVOT_VALUE);
    rotateAnimation.setDuration(DEFAULT_ROTATE_DURATION_MS);
    rotateAnimation.setFillAfter(true);
    mArrowExpandImageView.startAnimation(rotateAnimation);
}
 
源代码5 项目: RecyclerViewManager   文件: RefreshHeader.java
private void buildAnimation() {
    mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(mRotateAniTime);
    mFlipAnimation.setFillAfter(true);

    mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(mRotateAniTime);
    mReverseFlipAnimation.setFillAfter(true);
}
 
源代码6 项目: AndroidPlusJava   文件: AboutActivity.java
@OnClick(R.id.about_info)
public void onViewClicked() {
    RotateAnimation rotateAnimation = new RotateAnimation(0, 1080,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(1000);
    rotateAnimation.setInterpolator(new AccelerateInterpolator());
    mAboutInfo.startAnimation(rotateAnimation);
}
 
private void buildAnimation() {
    mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(mRotateAniTime);
    mFlipAnimation.setFillAfter(true);

    mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(mRotateAniTime);
    mReverseFlipAnimation.setFillAfter(true);
}
 
源代码8 项目: Swface   文件: PtrClassicDefaultHeader.java
private void buildAnimation() {
    mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(mRotateAniTime);
    mFlipAnimation.setFillAfter(true);

    mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(mRotateAniTime);
    mReverseFlipAnimation.setFillAfter(true);
}
 
public AbsClassicRefreshView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mStyle = new me.dkzwm.widget.srl.extra.RefreshViewStyle(context, attrs, defStyleAttr, 0);
    mFlipAnimation =
            new RotateAnimation(
                    0,
                    -180,
                    RotateAnimation.RELATIVE_TO_SELF,
                    0.5f,
                    RotateAnimation.RELATIVE_TO_SELF,
                    0.5f);
    mFlipAnimation.setInterpolator(sLinearInterpolator);
    mFlipAnimation.setDuration(mRotateAniTime);
    mFlipAnimation.setFillAfter(true);

    mReverseFlipAnimation =
            new RotateAnimation(
                    -180,
                    0,
                    RotateAnimation.RELATIVE_TO_SELF,
                    0.5f,
                    RotateAnimation.RELATIVE_TO_SELF,
                    0.5f);
    mReverseFlipAnimation.setInterpolator(sLinearInterpolator);
    mReverseFlipAnimation.setDuration(mRotateAniTime);
    mReverseFlipAnimation.setFillAfter(true);
    createClassicViews();
    mArrowImageView = findViewById(R.id.sr_classic_arrow);
    mTitleTextView = findViewById(R.id.sr_classic_title);
    mLastUpdateTextView = findViewById(R.id.sr_classic_last_update);
    mProgressBar = findViewById(R.id.sr_classic_progress);
    mLastUpdateTimeUpdater = new LastUpdateTimeUpdater(this);
    mArrowImageView.clearAnimation();
    mArrowImageView.setVisibility(VISIBLE);
    mProgressBar.setVisibility(INVISIBLE);
}
 
public static void rotationAnimation(View view, AnimationListener listener) {
	if(view==null)
		return;
	
	final RotateAnimation rotation = new RotateAnimation(0, 180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	rotation.setDuration(300);
	rotation.setFillAfter(true);
	if(listener!=null)
		rotation.setAnimationListener(listener);
	
	view.startAnimation(rotation);
}
 
public TraditionFooterAdapter(Context context) {
    super(context);
    mFlipAnimation = new RotateAnimation(0, -180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
}
 
public TraditionHeaderAdapter(Context context) {
    super(context);
    mFlipAnimation = new RotateAnimation(0, -180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
}
 
源代码13 项目: bleYan   文件: VerticalParentViewHolder.java
@Override
public void onExpansionToggled(boolean isExpanded) {
    super.onExpansionToggled(isExpanded);
    if (!HONEYCOMB_AND_ABOVE) {
        return;
    }

    RotateAnimation rotateAnimation = new RotateAnimation(ROTATED_POSITION,
            INITIAL_POSITION,
            RotateAnimation.RELATIVE_TO_SELF, PIVOT_VALUE,
            RotateAnimation.RELATIVE_TO_SELF, PIVOT_VALUE);
    rotateAnimation.setDuration(DEFAULT_ROTATE_DURATION_MS);
    rotateAnimation.setFillAfter(true);
    mArrowExpandImageView.startAnimation(rotateAnimation);
}
 
源代码14 项目: Study_Android_Demo   文件: MainActivity.java
public void rotateAnim_java(View view) {
	// 2.����RotateAnimation
	RotateAnimation animation = new RotateAnimation(-45f, 45f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0f);
	animation.setDuration(1000);
	animation.setRepeatCount(Animation.INFINITE);
	animation.setRepeatMode(Animation.REVERSE);
	animation.setInterpolator(new LinearInterpolator());
	// 3.���Ŷ���
	iv_rocket.startAnimation(animation);

}
 
源代码15 项目: PullListView   文件: PullListView.java
/**
 * 初始化动画
 */
private void initAnimation() {
    // 旋转
    animation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(300);
    animation.setFillAfter(true);

    //反向旋转
    reverseAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    reverseAnimation.setInterpolator(new LinearInterpolator());
    reverseAnimation.setDuration(300);
    reverseAnimation.setFillAfter(true);
}
 
源代码16 项目: AndroidHeros   文件: MainActivity.java
public void btnRotateSelf(View view) {
    RotateAnimation ra = new RotateAnimation(0, 360,
            RotateAnimation.RELATIVE_TO_SELF, 0.5F,
            RotateAnimation.RELATIVE_TO_SELF, 0.5F);
    ra.setDuration(1000);
    view.startAnimation(ra);

}
 
源代码17 项目: LiveSourceCode   文件: PtrClassicDefaultHeader.java
private void buildAnimation() {
    mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(mRotateAniTime);
    mFlipAnimation.setFillAfter(true);

    mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(mRotateAniTime);
    mReverseFlipAnimation.setFillAfter(true);
}
 
源代码18 项目: UltimateAndroid   文件: DropDownListView.java
/**
 * init drop down style, only init once
 */
private void initDropDownStyle() {
    if (headerLayout != null) {
        if (isDropDownStyle) {
            addHeaderView(headerLayout);
        } else {
            removeHeaderView(headerLayout);
        }
        return;
    }
    if (!isDropDownStyle) {
        return;
    }

    headerReleaseMinDistance = context.getResources().getDimensionPixelSize(
            R.dimen.drop_down_list_header_release_min_distance);
    flipAnimation = new RotateAnimation(0, 180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    flipAnimation.setInterpolator(new LinearInterpolator());
    flipAnimation.setDuration(250);
    flipAnimation.setFillAfter(true);
    reverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    reverseFlipAnimation.setInterpolator(new LinearInterpolator());
    reverseFlipAnimation.setDuration(250);
    reverseFlipAnimation.setFillAfter(true);

    headerDefaultText = context.getString(R.string.drop_down_list_header_default_text);
    headerPullText = context.getString(R.string.drop_down_list_header_pull_text);
    headerReleaseText = context.getString(R.string.drop_down_list_header_release_text);
    headerLoadingText = context.getString(R.string.drop_down_list_header_loading_text);

    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    headerLayout = (RelativeLayout)inflater.inflate(R.layout.drop_down_list_header, this, false);
    headerText = (TextView)headerLayout.findViewById(R.id.drop_down_list_header_default_text);
    headerImage = (ImageView)headerLayout.findViewById(R.id.drop_down_list_header_image);
    headerProgressBar = (ProgressBar)headerLayout.findViewById(R.id.drop_down_list_header_progress_bar);
    headerSecondText = (TextView)headerLayout.findViewById(R.id.drop_down_list_header_second_text);
    headerLayout.setClickable(true);
    headerLayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onDropDown();
        }
    });
    headerText.setText(headerDefaultText);
    addHeaderView(headerLayout);

    measureHeaderLayout(headerLayout);
    headerOriginalHeight = headerLayout.getMeasuredHeight();
    headerOriginalTopPadding = headerLayout.getPaddingTop();
    currentHeaderStatus = HEADER_STATUS_CLICK_TO_LOAD;
}
 
源代码19 项目: appcan-android   文件: EBounceViewHeader.java
public EBounceViewHeader(Context context, int type) {
    super(context);
    setWillNotDraw(true);
    setBackgroundColor(0);
    setFocusable(false);
    ESystemInfo intence = ESystemInfo.getIntence();
    int height = intence.mDefaultBounceHeight;
    RelativeLayout wapper = new RelativeLayout(context);
    wapper.setWillNotDraw(true);
    wapper.setBackgroundColor(0);
    wapper.setFocusable(false);
    RelativeLayout.LayoutParams wParm = new LayoutParams(-1, height);
    if (type == EViewEntry.F_BOUNCE_TYPE_TOP) {
        wParm.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    } else {
        wParm.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    }
    wapper.setLayoutParams(wParm);
    addView(wapper);

    wap = new RelativeLayout(context);
    wap.setId(F_WAP_ID);
    RelativeLayout.LayoutParams wm = new LayoutParams(-2, height);
    wm.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    wm.leftMargin = 30;
    wap.setLayoutParams(wm);

    mContent = new TextView(context);
    mContent.setId(F_CONTENT_ID);
    RelativeLayout.LayoutParams parmMsg = new LayoutParams(-2, -2);
    parmMsg.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mContent.setLayoutParams(parmMsg);
    mContent.setTextColor(textColor);
    mContent.setText(pullToReloadText);
    mContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float) (intence.mDefaultNatvieFontSize));
    mContent.setVisibility(GONE);
    wap.addView(mContent);

    mLevelContent = new TextView(context);
    RelativeLayout.LayoutParams parml = new LayoutParams(-2, -2);
    parml.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    parml.addRule(RelativeLayout.BELOW, F_CONTENT_ID);
    mLevelContent.setLayoutParams(parml);
    mLevelContent.setTextColor(textColor);
    mLevelContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float) (intence.mDefaultNatvieFontSize * 0.6));
    mLevelContent.setVisibility(GONE);
    wap.addView(mLevelContent);

    wapper.addView(wap);

    mProgress = new ProgressBar(context);
    mProgress.setIndeterminate(true);
    int use = height - 12;
    RelativeLayout.LayoutParams parmPro = new LayoutParams(use, use);
    parmPro.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmPro.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mProgress.setLayoutParams(parmPro);
    mProgress.setVisibility(GONE);
    wapper.addView(mProgress);

    mYAxisProgress = new YAxisImageView(context);
    int useY = height - 12;
    RelativeLayout.LayoutParams parmProY = new LayoutParams(useY, useY);
    parmProY.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmProY.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mYAxisProgress.setLayoutParams(parmProY);
    mYAxisProgress.setVisibility(GONE);
    wapper.addView(mYAxisProgress);

    mArrowImage = new ImageView(context);
    int useA = height - 12;
    RelativeLayout.LayoutParams parmImage = new LayoutParams(useA, useA);
    parmImage.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmImage.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mArrowImage.setLayoutParams(parmImage);
    Drawable icon = context.getResources().getDrawable(EResources.platform_myspace_pulltorefresh_arrow);
    mArrowImage.setImageDrawable(icon);
    mArrowImage.setVisibility(GONE);
    wapper.addView(mArrowImage);

    mAnimationUp = new RotateAnimation(-180, 0,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mAnimationUp.setInterpolator(new AccelerateInterpolator());
    mAnimationUp.setDuration(250);
    mAnimationUp.setFillAfter(true);

    mAnimationDown = new RotateAnimation(0, -180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mAnimationDown.setInterpolator(new AccelerateInterpolator());
    mAnimationDown.setDuration(250);
    mAnimationDown.setFillAfter(true);
}
 
private void initAnimations() {
	mTurnupAnimation = new RotateAnimation(0, -180,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mTurnupAnimation.setInterpolator(new LinearInterpolator());
	mTurnupAnimation.setDuration(500);
	mTurnupAnimation.setFillAfter(true);

	mTurndownAnimation = new RotateAnimation(-180, 0,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mTurndownAnimation.setInterpolator(new LinearInterpolator());
	mTurndownAnimation.setDuration(500);
	mTurndownAnimation.setFillAfter(true);

	mTranslateAnimationOne = new TranslateAnimation(0, 100, 0, 100);
	mTranslateAnimationOne
			.setInterpolator(new AccelerateDecelerateInterpolator());
	mTranslateAnimationOne.setDuration(1000);
	mTranslateAnimationOne.setFillAfter(true);

	mTranslateAnimationTwo = new TranslateAnimation(100, 100, 0, 100);
	mTranslateAnimationTwo
			.setInterpolator(new AccelerateDecelerateInterpolator());
	mTranslateAnimationTwo.setDuration(1000);
	mTranslateAnimationTwo.setFillAfter(true);

	mAlphaAnimationOne = new AlphaAnimation(1, 0);
	mAlphaAnimationOne.setDuration(500);
	mAlphaAnimationOne.setFillAfter(true);

	mAlphaAnimationTwo = new AlphaAnimation(0, 1);
	mAlphaAnimationTwo.setDuration(1000);
	mAlphaAnimationTwo.setStartOffset(500);
	mAlphaAnimationTwo.setFillAfter(true);

	mAlphaAnimationSet = new AnimationSet(false);
	mAlphaAnimationSet.addAnimation(mAlphaAnimationOne);
	mAlphaAnimationSet.addAnimation(mAlphaAnimationTwo);
	mAlphaAnimationSet.setDuration(5000);

	mAlphaAnimationSet.setFillAfter(true);

	mScaleAnimation = new ScaleAnimation(1, 1.5f, 1, 1.5f);
	mScaleAnimation.setDuration(1000);
	mScaleAnimation.setFillAfter(true);

}