Java Code Examples for android.view.animation.AnimationUtils#loadInterpolator()
The following examples show how to use
android.view.animation.AnimationUtils#loadInterpolator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimUtils.java From android-proguards with Apache License 2.0 | 5 votes |
public static Interpolator getFastOutSlowInInterpolator(Context context) { if (fastOutSlowIn == null) { fastOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in); } return fastOutSlowIn; }
Example 2
Source File: FloatLabelLayout.java From xifan with Apache License 2.0 | 5 votes |
public FloatLabelLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setOrientation(VERTICAL); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout); int leftPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft, dipsToPix(DEFAULT_LABEL_PADDING_LEFT)); int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop, dipsToPix(DEFAULT_LABEL_PADDING_TOP)); int rightPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight, dipsToPix(DEFAULT_LABEL_PADDING_RIGHT)); int bottomPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom, dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM)); mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint); mLabel = new TextView(context); mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding); mLabel.setVisibility(INVISIBLE); mLabel.setText(mHint); ViewCompat.setPivotX(mLabel, 0f); ViewCompat.setPivotY(mLabel, 0f); mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance, android.R.style.TextAppearance_Small)); a.recycle(); addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mInterpolator = AnimationUtils.loadInterpolator(context, Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.interpolator.fast_out_slow_in : android.R.anim.decelerate_interpolator); }
Example 3
Source File: AnimUtils.java From YiZhi with Apache License 2.0 | 5 votes |
public static Interpolator getFastOutLinearInInterpolator(Context context) { if (fastOutLinearIn == null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { fastOutLinearIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_linear_in); } } return fastOutLinearIn; }
Example 4
Source File: AnimUtils.java From YiZhi with Apache License 2.0 | 5 votes |
public static Interpolator getLinearOutSlowInInterpolator(Context context) { if (linearOutSlowIn == null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { linearOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in); } } return linearOutSlowIn; }
Example 5
Source File: AnimUtils.java From MyBlogDemo with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Interpolator getFastOutLinearInInterpolator(Context context) { if (fastOutLinearIn == null) { fastOutLinearIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_linear_in); } return fastOutLinearIn; }
Example 6
Source File: DockedStackDividerController.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
DockedStackDividerController(WindowManagerService service, DisplayContent displayContent) { mService = service; mDisplayContent = displayContent; final Context context = service.mContext; mMinimizedDockInterpolator = AnimationUtils.loadInterpolator( context, android.R.interpolator.fast_out_slow_in); loadDimens(); }
Example 7
Source File: AnimUtils.java From MyBlogDemo with Apache License 2.0 | 5 votes |
public static Interpolator getFastOutSlowInInterpolator(Context context) { if (fastOutSlowIn == null) { fastOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in); } return fastOutSlowIn; }
Example 8
Source File: AnimUtils.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) static Interpolator getFastOutSlowInInterpolator(Context context) { if (fastOutSlowIn == null) { fastOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in); } return fastOutSlowIn; }
Example 9
Source File: AnimUtils.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
public static Interpolator getFastOutSlowInInterpolator(Context context) { if (fastOutSlowIn == null) { fastOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in); } return fastOutSlowIn; }
Example 10
Source File: ExpandableSelectorAnimator.java From ExpandableSelector with Apache License 2.0 | 4 votes |
private Interpolator getContainerAnimationInterpolator() { return AnimationUtils.loadInterpolator(container.getContext(), containerInterpolatorId); }
Example 11
Source File: PostActivity.java From materialup with Apache License 2.0 | 4 votes |
/** * Animate in the title, description and author – can't do this in a content transition as they * are within the ListView so do it manually. Also handle the FAB tanslation here so that it * plays nicely with #calculateFabPosition */ private void enterAnimation(boolean isOrientationChange) { Interpolator interp = null; if (UI.isLollipop()) { interp = AnimationUtils.loadInterpolator(this, android.R.interpolator .fast_out_slow_in); } else { interp = AnimationUtils.loadInterpolator(this, android.R.interpolator .accelerate_decelerate); } int offset = title.getHeight(); viewEnterAnimation(title, offset, interp); if (description.getVisibility() == View.VISIBLE) { offset *= 1.5f; viewEnterAnimation(description, offset, interp); } // animate the fab without touching the alpha as this is handled in the content transition offset *= 1.5f; float fabTransY = fab.getTranslationY(); fab.setTranslationY(fabTransY + offset); fab.animate() .translationY(fabTransY) .setDuration(600) .setInterpolator(interp) .start(); offset *= 1.5f; viewEnterAnimation(shotActions, offset, interp); offset *= 1.5f; viewEnterAnimation(playerName, offset, interp); viewEnterAnimation(playerAvatar, offset, interp); viewEnterAnimation(shotTimeAgo, offset, interp); back.animate() .alpha(1f) .setDuration(600) .setInterpolator(interp) .start(); source.animate() .alpha(1f) .setDuration(600) .setInterpolator(interp) .start(); if (isOrientationChange) { // we rely on the window enter content transition to show the fab. This isn't run on // orientation changes so manually show it. Animator showFab = ObjectAnimator.ofPropertyValuesHolder(fab, PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f), PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f)); showFab.setStartDelay(300L); showFab.setDuration(300L); showFab.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); showFab.start(); } }
Example 12
Source File: InfiniteCycleManager.java From InfiniteCycleViewPager with Apache License 2.0 | 4 votes |
public void processAttributeSet(final AttributeSet attributeSet) { if (attributeSet == null) return; final TypedArray typedArray = mContext.obtainStyledAttributes( attributeSet, mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager : R.styleable.HorizontalInfiniteCycleViewPager ); try { setMinPageScaleOffset( typedArray.getDimension( mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_min_page_scale_offset : R.styleable.HorizontalInfiniteCycleViewPager_icvp_min_page_scale_offset, DEFAULT_MIN_PAGE_SCALE_OFFSET ) ); setCenterPageScaleOffset( typedArray.getDimension( mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_center_page_scale_offset : R.styleable.HorizontalInfiniteCycleViewPager_icvp_center_page_scale_offset, DEFAULT_CENTER_PAGE_SCALE_OFFSET ) ); setMinPageScale( typedArray.getFloat( mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_min_page_scale : R.styleable.HorizontalInfiniteCycleViewPager_icvp_min_page_scale, DEFAULT_MIN_SCALE ) ); setMaxPageScale( typedArray.getFloat( mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_max_page_scale : R.styleable.HorizontalInfiniteCycleViewPager_icvp_max_page_scale, DEFAULT_MAX_SCALE ) ); setMediumScaled( typedArray.getBoolean( mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_medium_scaled : R.styleable.HorizontalInfiniteCycleViewPager_icvp_medium_scaled, DEFAULT_IS_MEDIUM_SCALED ) ); setScrollDuration( typedArray.getInteger( mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_scroll_duration : R.styleable.HorizontalInfiniteCycleViewPager_icvp_scroll_duration, DEFAULT_SCROLL_DURATION ) ); setPageDuration( typedArray.getInteger( mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_page_duration : R.styleable.HorizontalInfiniteCycleViewPager_icvp_page_duration, DEFAULT_SCROLL_DURATION ) ); // Retrieve interpolator Interpolator interpolator = null; try { final int interpolatorId = typedArray.getResourceId( mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_interpolator : R.styleable.HorizontalInfiniteCycleViewPager_icvp_interpolator, 0 ); interpolator = interpolatorId == 0 ? null : AnimationUtils.loadInterpolator(mContext, interpolatorId); } catch (Resources.NotFoundException exception) { interpolator = null; exception.printStackTrace(); } finally { setInterpolator(interpolator); } } finally { typedArray.recycle(); } }
Example 13
Source File: Fab.java From faveo-helpdesk-android-app with Open Software License 3.0 | 4 votes |
private Interpolator getInterpolator() { return AnimationUtils.loadInterpolator(getContext(), R.interpolator.msf_interpolator); }
Example 14
Source File: Kawaii_LoadingView.java From Kawaii_LoadingView with Apache License 2.0 | 4 votes |
/** * 步骤1:初始化动画的属性 */ private void initAttrs(Context context, AttributeSet attrs) { // 控件资源名称 TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Kawaii_LoadingView); // 方块行数量(最少3行) lineNumber = typedArray.getInteger(R.styleable.Kawaii_LoadingView_lineNumber, 3); if (lineNumber < 3) { lineNumber = 3; } // 半个方块的宽度(dp) half_BlockWidth = typedArray.getDimension(R.styleable.Kawaii_LoadingView_half_BlockWidth, 30); // 方块间隔宽度(dp) blockInterval = typedArray.getDimension(R.styleable.Kawaii_LoadingView_blockInterval, 10); // 移动方块的圆角半径 moveBlock_Angle = typedArray.getFloat(R.styleable.Kawaii_LoadingView_moveBlock_Angle, 10); // 固定方块的圆角半径 fixBlock_Angle = typedArray.getFloat(R.styleable.Kawaii_LoadingView_fixBlock_Angle, 30); // 通过设置两个方块的圆角半径使得二者不同可以得到更好的动画效果哦 // 方块颜色(使用十六进制代码,如#333、#8e8e8e) int defaultColor = context.getResources().getColor(R.color.colorAccent); // 默认颜色 blockColor = typedArray.getColor(R.styleable.Kawaii_LoadingView_blockColor, defaultColor); // 移动方块的初始位置(即空白位置) initPosition = typedArray.getInteger(R.styleable.Kawaii_LoadingView_initPosition, 0); // 由于移动方块只能是外部方块,所以这里需要判断方块是否属于外部方块 -->关注1 if (isInsideTheRect(initPosition, lineNumber)) { initPosition = 0; } // 动画方向是否 = 顺时针旋转 isClock_Wise = typedArray.getBoolean(R.styleable.Kawaii_LoadingView_isClock_Wise, true); // 移动方块的移动速度 // 注:不建议使用者将速度调得过快 // 因为会导致ValueAnimator动画对象频繁重复的创建,存在内存抖动 moveSpeed = typedArray.getInteger(R.styleable.Kawaii_LoadingView_moveSpeed, 250); // 设置移动方块动画的插值器 int move_InterpolatorResId = typedArray.getResourceId(R.styleable.Kawaii_LoadingView_move_Interpolator, android.R.anim.linear_interpolator); move_Interpolator = AnimationUtils.loadInterpolator(context, move_InterpolatorResId); // 当方块移动后,需要实时更新的空白方块的位置 mCurrEmptyPosition = initPosition; // 释放资源 typedArray.recycle(); }
Example 15
Source File: AnimatorInflater.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private static Keyframe loadKeyframe(Resources res, Theme theme, AttributeSet attrs, int valueType) throws XmlPullParserException, IOException { TypedArray a; if (theme != null) { a = theme.obtainStyledAttributes(attrs, R.styleable.Keyframe, 0, 0); } else { a = res.obtainAttributes(attrs, R.styleable.Keyframe); } Keyframe keyframe = null; float fraction = a.getFloat(R.styleable.Keyframe_fraction, -1); TypedValue keyframeValue = a.peekValue(R.styleable.Keyframe_value); boolean hasValue = (keyframeValue != null); if (valueType == VALUE_TYPE_UNDEFINED) { // When no value type is provided, check whether it's a color type first. // If not, fall back to default value type (i.e. float type). if (hasValue && isColorType(keyframeValue.type)) { valueType = VALUE_TYPE_COLOR; } else { valueType = VALUE_TYPE_FLOAT; } } if (hasValue) { switch (valueType) { case VALUE_TYPE_FLOAT: float value = a.getFloat(R.styleable.Keyframe_value, 0); keyframe = Keyframe.ofFloat(fraction, value); break; case VALUE_TYPE_COLOR: case VALUE_TYPE_INT: int intValue = a.getInt(R.styleable.Keyframe_value, 0); keyframe = Keyframe.ofInt(fraction, intValue); break; } } else { keyframe = (valueType == VALUE_TYPE_FLOAT) ? Keyframe.ofFloat(fraction) : Keyframe.ofInt(fraction); } final int resID = a.getResourceId(R.styleable.Keyframe_interpolator, 0); if (resID > 0) { final Interpolator interpolator = AnimationUtils.loadInterpolator(res, theme, resID); keyframe.setInterpolator(interpolator); } a.recycle(); return keyframe; }
Example 16
Source File: DefaultScrollbarVertical.java From ProjectX with Apache License 2.0 | 4 votes |
@Override public void onConstruct(ScrollbarRecyclerView view, Context context, TypedArray custom) { final float density = context.getResources().getDisplayMetrics().density; if (Utils.hasValueOrEmpty(custom, R.styleable.ScrollbarRecyclerView_dsVerticalBackground)) { mBackground = custom.getDrawable( R.styleable.ScrollbarRecyclerView_dsVerticalBackground); } else { mBackground = Utils.getDefaultBackground(context); } mPaddingEdge = custom.getDimensionPixelSize( R.styleable.ScrollbarRecyclerView_dsVerticalPaddingEdge, 0); mPaddingStart = custom.getDimensionPixelSize( R.styleable.ScrollbarRecyclerView_dsVerticalPaddingStart, 0); mPaddingEnd = custom.getDimensionPixelSize( R.styleable.ScrollbarRecyclerView_dsVerticalPaddingEnd, 0); if (Utils.hasValueOrEmpty(custom, R.styleable.ScrollbarRecyclerView_dsVerticalSlider)) { mSlider = custom.getDrawable( R.styleable.ScrollbarRecyclerView_dsVerticalSlider); } else { mSlider = Utils.getDefaultVerticalSlider(context); } mIndicatorPadding = custom.getDimensionPixelSize( R.styleable.ScrollbarRecyclerView_dsVerticalIndicatorPadding, 0); if (Utils.hasValueOrEmpty(custom, R.styleable.ScrollbarRecyclerView_dsVerticalIndicator)) { mIndicator = custom.getDrawable( R.styleable.ScrollbarRecyclerView_dsVerticalIndicator); } else { mIndicator = Utils.getDefaultVerticalIndicator(context); } mIndicatorGravity = custom.getInt( R.styleable.ScrollbarRecyclerView_dsVerticalIndicatorGravity, DefaultScrollbar.GRAVITY_CENTER); mIndicatorInside = custom.getBoolean( R.styleable.ScrollbarRecyclerView_dsVerticalIndicatorInside, false); mTextColor = custom.getColor( R.styleable.ScrollbarRecyclerView_dsVerticalTextColor, Color.WHITE); mTextSize = custom.getDimensionPixelOffset( R.styleable.ScrollbarRecyclerView_dsVerticalTextSize, (int) (density * 24)); mTouchStartOnBar = custom.getBoolean( R.styleable.ScrollbarRecyclerView_dsVerticalTouchStartOnBar, false); mAnimatorType = custom.getInt( R.styleable.ScrollbarRecyclerView_dsVerticalAnimator, DefaultScrollbar.ANIMATOR_TYPE_ALL); mAlwaysTouchable = custom.getBoolean( R.styleable.ScrollbarRecyclerView_dsVerticalAlwaysTouchable, false); mBackgroundWidth = mBackground == null ? 0 : mBackground.getIntrinsicWidth(); mSliderWidth = mSlider == null ? 0 : mSlider.getIntrinsicWidth(); mSliderHeight = mSlider == null ? 0 : mSlider.getIntrinsicHeight(); mIndicatorWidth = mIndicator == null ? 0 : mIndicator.getIntrinsicWidth(); mIndicatorHeight = mIndicator == null ? 0 : mIndicator.getIntrinsicHeight(); Interpolator interpolator = AnimationUtils.loadInterpolator(context, android.R.interpolator.accelerate_quad); mAnimatorDelay = custom.getInt( R.styleable.ScrollbarRecyclerView_dsVerticalAnimatorDelay, 3000); mAnimation.attach(view); mAnimation.setDuration(custom.getInt( R.styleable.ScrollbarRecyclerView_dsVerticalAnimatorDuration, 1500)); mAnimation.setInterpolator(interpolator); if (mAnimatorType != DefaultScrollbar.ANIMATOR_TYPE_NONE) mAnimation.startDelayed(mAnimatorDelay); mIndicatorAnimation.setDuration(250); mIndicatorAnimation.setInterpolator(interpolator); mShowIndicator = view.isInEditMode(); }
Example 17
Source File: AnimUtils.java From star-zone-android with Apache License 2.0 | 4 votes |
public static Interpolator getLinearOutSlowInInterpolator(Context context) { if (linearOutSlowIn == null) { linearOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in); } return linearOutSlowIn; }
Example 18
Source File: ExpandableSelectorAnimator.java From ExpandableSelector with Apache License 2.0 | 4 votes |
private TimeInterpolator getCollapseAnimatorInterpolation() { return AnimationUtils.loadInterpolator(container.getContext(), collapseInterpolatorId); }
Example 19
Source File: PulseView.java From PulseView with Apache License 2.0 | 4 votes |
public PulseView(final Context context, final AttributeSet attrs, final int defStyleAttr) { super(context, attrs, defStyleAttr); // Always draw and improve speed setWillNotDraw(false); setLayerType(LAYER_TYPE_HARDWARE, null); // Get attrs final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PulseView); try { setIconRes(typedArray.getResourceId(R.styleable.PulseView_pv_icon, 0)); setIconWidth((int) typedArray.getDimension(R.styleable.PulseView_pv_icon_width, 0)); setIconHeight((int) typedArray.getDimension(R.styleable.PulseView_pv_icon_height, 0)); setPulseCount( typedArray.getInteger(R.styleable.PulseView_pv_count, DEFAULT_PULSE_COUNT) ); setPulseSpawnPeriod( typedArray.getInteger( R.styleable.PulseView_pv_spawn_period, DEFAULT_PULSE_SPAWN_PERIOD ) ); setPulseAlpha(typedArray.getInteger(R.styleable.PulseView_pv_alpha, DEFAULT_PULSE_ALPHA)); setPulseColor(typedArray.getColor(R.styleable.PulseView_pv_color, DEFAULT_PULSE_COLOR)); setPulseMeasure( typedArray.getInt(R.styleable.PulseView_pv_measure, DEFAULT_PULSE_MEASURE) ); // Retrieve interpolator Interpolator interpolator = null; try { final int interpolatorId = typedArray.getResourceId( R.styleable.PulseView_pv_interpolator, 0 ); interpolator = interpolatorId == 0 ? null : AnimationUtils.loadInterpolator(context, interpolatorId); } catch (Resources.NotFoundException exception) { interpolator = null; exception.printStackTrace(); } finally { setInterpolator(interpolator); } } finally { typedArray.recycle(); } }
Example 20
Source File: MasaccioImageView.java From Masaccio with Apache License 2.0 | 2 votes |
private void init(final AttributeSet attrs, final int defStyle) { // Read attributes final TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.MasaccioImageView, defStyle, 0); mActivateDetectionFlags = typedArray.getInt(R.styleable.MasaccioImageView_activate_face_detection, 0); mActivateMatrixFlags = typedArray.getInt(R.styleable.MasaccioImageView_activate_matrix, 0); final boolean autoFaceDetection = typedArray.getBoolean(R.styleable.MasaccioImageView_center_face, false); mStartScale = typedArray.getFloat(R.styleable.MasaccioImageView_pre_scale, -1); mStartX = typedArray.getFloat(R.styleable.MasaccioImageView_pre_translate_x, 0); mStartY = typedArray.getFloat(R.styleable.MasaccioImageView_pre_translate_y, 0); mEndScale = typedArray.getFloat(R.styleable.MasaccioImageView_scale, -1); mEndX = typedArray.getFloat(R.styleable.MasaccioImageView_translate_x, 0); mEndY = typedArray.getFloat(R.styleable.MasaccioImageView_translate_y, 0); mAnimationDuration = typedArray.getInt(R.styleable.MasaccioImageView_animation_duration, 0); final int interpolatorId = typedArray.getResourceId(R.styleable.MasaccioImageView_animation_interpolator, NO_ID); mCyclicAnimation = typedArray.getBoolean(R.styleable.MasaccioImageView_cyclic_animation, false); mOriginalScaleType = getScaleType(); mMessageHandler = new Handler(); if (interpolatorId != NO_ID) { mInterpolator = AnimationUtils.loadInterpolator(getContext(), interpolatorId); } else { mInterpolator = mDefaultInterpolator; } setCenterFace(autoFaceDetection); }