当前位置: 首页>>代码示例>>Java>>正文


Java StateListAnimator类代码示例

本文整理汇总了Java中android.animation.StateListAnimator的典型用法代码示例。如果您正苦于以下问题:Java StateListAnimator类的具体用法?Java StateListAnimator怎么用?Java StateListAnimator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StateListAnimator类属于android.animation包,在下文中一共展示了StateListAnimator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.animation.StateListAnimator; //导入依赖的package包/类
@SuppressLint("NewApi")
private void init(Context context, AttributeSet attributeSet) {
    mVisible = true;
    mColorNormal = getColor(R.color.material_blue_500);
    mColorPressed = darkenColor(mColorNormal);
    mColorRipple = lightenColor(mColorNormal);
    mColorDisabled = getColor(android.R.color.darker_gray);
    mType = TYPE_NORMAL;
    mShadow = true;
    mScrollThreshold = getResources().getDimensionPixelOffset(R.dimen.fab_scroll_threshold);
    mShadowSize = getDimension(R.dimen.fab_shadow_size);
    if (hasLollipopApi()) {
        StateListAnimator stateListAnimator = AnimatorInflater.loadStateListAnimator(context,
                R.animator.fab_press_elevation);
        setStateListAnimator(stateListAnimator);
    }
    if (attributeSet != null) {
        initAttributes(context, attributeSet);
    }
    updateBackground();
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:22,代码来源:FloatingActionButton.java

示例2: setDefaultAppBarLayoutStateListAnimator

import android.animation.StateListAnimator; //导入依赖的package包/类
/**
   * Creates and sets a {@link StateListAnimator} with a custom elevation value
   */
static void setDefaultAppBarLayoutStateListAnimator(final View view, final float elevation) {
  final int dur = view.getResources().getInteger(R.integer.app_bar_elevation_anim_duration);

  final StateListAnimator sla = new StateListAnimator();

  // Enabled and collapsible, but not collapsed means not elevated
      sla.addState(new int[]{android.R.attr.enabled, R.attr.state_collapsible,
                      -R.attr.state_collapsed},
      ObjectAnimator.ofFloat(view, "elevation", 0f).setDuration(dur));

  // Default enabled state
      sla.addState(new int[]{android.R.attr.enabled},
      ObjectAnimator.ofFloat(view, "elevation", elevation).setDuration(dur));

  // Disabled state
      sla.addState(new int[0],
              ObjectAnimator.ofFloat(view, "elevation", 0).setDuration(0));

  view.setStateListAnimator(sla);
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:24,代码来源:ViewUtilsLollipop.java

示例3: ViewHolder

import android.animation.StateListAnimator; //导入依赖的package包/类
ViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    setCardViewToFlat(card);

    if (!Preferences.get(mContext).isShadowEnabled()) {
        card.setCardElevation(0f);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StateListAnimator stateListAnimator = AnimatorInflater
                .loadStateListAnimator(mContext, R.animator.card_lift_long);
        card.setStateListAnimator(stateListAnimator);
    }

    card.setOnClickListener(this);
    card.setOnLongClickListener(this);
    favorite.setOnClickListener(this);
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:20,代码来源:WallpapersAdapter.java

示例4: setDefaultAppBarLayoutStateListAnimator

import android.animation.StateListAnimator; //导入依赖的package包/类
/**
 * Creates and sets a {@link StateListAnimator} with a custom elevation value
 */
@SuppressLint("PrivateResource")
static void setDefaultAppBarLayoutStateListAnimator(final View view, final float targetElevation) {
    final StateListAnimator sla = new StateListAnimator();

    // Enabled, collapsible and collapsed == elevated
    sla.addState(new int[]{android.R.attr.enabled, R.attr.state_collapsible, R.attr.state_collapsed},
            ObjectAnimator.ofFloat(view, "elevation", targetElevation));

    // Enabled and collapsible, but not collapsed != elevated
    sla.addState(new int[]{android.R.attr.enabled, R.attr.state_collapsible, -R.attr.state_collapsed},
            ObjectAnimator.ofFloat(view, "elevation", 0f));

    // Enabled but not collapsible == elevated
    sla.addState(new int[]{android.R.attr.enabled, -R.attr.state_collapsible},
            ObjectAnimator.ofFloat(view, "elevation", targetElevation));

    // Default, none elevated state
    sla.addState(new int[0], ObjectAnimator.ofFloat(view, "elevation", 0));

    view.setStateListAnimator(sla);
}
 
开发者ID:VyacheslavShmakin,项目名称:GpCollapsingToolbar,代码行数:25,代码来源:ViewUtilsLollipop.java

示例5: onTranslationZChanged

import android.animation.StateListAnimator; //导入依赖的package包/类
@Override
void onTranslationZChanged(float translationZ) {
    StateListAnimator stateListAnimator = new StateListAnimator();
    // Animate translationZ to our value when pressed or focused
    stateListAnimator.addState(PRESSED_ENABLED_STATE_SET,
            setupAnimator(ObjectAnimator.ofFloat(mView, "translationZ", translationZ)));
    stateListAnimator.addState(FOCUSED_ENABLED_STATE_SET,
            setupAnimator(ObjectAnimator.ofFloat(mView, "translationZ", translationZ)));
    // Animate translationZ to 0 otherwise
    stateListAnimator.addState(EMPTY_STATE_SET,
            setupAnimator(ObjectAnimator.ofFloat(mView, "translationZ", 0f)));
    mView.setStateListAnimator(stateListAnimator);

    if (mShadowViewDelegate.isCompatPaddingEnabled()) {
        updatePadding();
    }
}
 
开发者ID:GigigoGreenLabs,项目名称:permissionsModule,代码行数:18,代码来源:FloatingActionButtonLollipop.java

示例6: setDefaultAppBarLayoutStateListAnimator

import android.animation.StateListAnimator; //导入依赖的package包/类
/** Creates and sets a {@link StateListAnimator} with a custom elevation value */
static void setDefaultAppBarLayoutStateListAnimator(final View view, final float elevation) {
  final int dur = view.getResources().getInteger(R.integer.app_bar_elevation_anim_duration);

  final StateListAnimator sla = new StateListAnimator();

  // Enabled and collapsible, but not collapsed means not elevated
  sla.addState(
      new int[] {android.R.attr.enabled, R.attr.state_collapsible, -R.attr.state_collapsed},
      ObjectAnimator.ofFloat(view, "elevation", 0f).setDuration(dur));

  // Default enabled state
  sla.addState(
      new int[] {android.R.attr.enabled},
      ObjectAnimator.ofFloat(view, "elevation", elevation).setDuration(dur));

  // Disabled state
  sla.addState(new int[0], ObjectAnimator.ofFloat(view, "elevation", 0).setDuration(0));

  view.setStateListAnimator(sla);
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:22,代码来源:ViewUtilsLollipop.java

示例7: init

import android.animation.StateListAnimator; //导入依赖的package包/类
@SuppressLint("NewApi")
private void init(Context context, AttributeSet attributeSet) {
    mVisible = true;
    mColorNormal = getColor(R.color.material_blue_500);
    mColorPressed = darkenColor(mColorNormal);
    mColorRipple = lightenColor(mColorNormal);
    mColorDisabled = getColor(android.R.color.darker_gray);
    mType = TYPE_NORMAL;
    mShadow = true;
    mScrollThreshold = getResources().getDimensionPixelOffset(R.dimen.fab_scroll_threshold);
    mShadowSize = getDimension(R.dimen.fab_shadow_size);
    if (hasLollipopApi()) {
        StateListAnimator stateListAnimator = AnimatorInflater.loadStateListAnimator(context,
                R.anim.fab_press_elevation);
        setStateListAnimator(stateListAnimator);
    }
    if (attributeSet != null) {
        initAttributes(context, attributeSet);
    }
    updateBackground();
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:22,代码来源:FloatingActionButton.java

示例8: init

import android.animation.StateListAnimator; //导入依赖的package包/类
@SuppressLint("NewApi")
private void init(Context context, AttributeSet attributeSet) {
	mVisible = true;
	mColorNormal = getColor(R.color.material_blue_500);
	mColorPressed = darkenColor(mColorNormal);
	mColorRipple = lightenColor(mColorNormal);
	mColorDisabled = getColor(android.R.color.darker_gray);
	mType = TYPE_NORMAL;
	mShadow = true;
	mScrollThreshold = getResources().getDimensionPixelOffset(
			R.dimen.fab_scroll_threshold);
	mShadowSize = getDimension(R.dimen.fab_shadow_size);
	if (hasLollipopApi()) {
		StateListAnimator stateListAnimator = AnimatorInflater
				.loadStateListAnimator(context, R.anim.fab_press_elevation);
		setStateListAnimator(stateListAnimator);
	}
	if (attributeSet != null) {
		initAttributes(context, attributeSet);
	}
	updateBackground();
}
 
开发者ID:himanshuagarwal77225,项目名称:BookMySkills,代码行数:23,代码来源:FloatingActionButton.java

示例9: initView

import android.animation.StateListAnimator; //导入依赖的package包/类
private void initView(Context context)
{
	inflater.inflate(R.layout.ms__button, this, true);

	Resources res = getResources();
	StateListAnimator sla = AnimatorInflater.loadStateListAnimator(context, R.animator.button_elevation);

	setBackground(res.getDrawable(R.drawable.button_background));
	setStateListAnimator(sla);
	setOrientation(LinearLayout.HORIZONTAL);
	setGravity(Gravity.CENTER);
	setOnClickListener(null);

	content = findViewById(R.id.ms__content);

	buttonIcon = (ImageView)content.findViewById(R.id.ms__button_icon);
	buttonIcon.setImageResource(mResource);
	buttonIcon.setImageDrawable(mDrawable);

	buttonText = (TextView)content.findViewById(R.id.ms__button_text);
	buttonText.setText(mText);
	buttonText.setTextColor(mTextColor);
	buttonText.setTextSize(mTextSize);
	if (mState)
	{
		buttonText.setTypeface(mTypface);
	}
	else
	{ }
}
 
开发者ID:MSay2,项目名称:Mire,代码行数:31,代码来源:ButtonIcon.java

示例10: setStateListAnimatorFromAttrs

import android.animation.StateListAnimator; //导入依赖的package包/类
static void setStateListAnimatorFromAttrs(View view, AttributeSet attrs,
         int defStyleAttr,  int defStyleRes) {
  final Context context = view.getContext();
      final TypedArray a = context.obtainStyledAttributes(attrs, STATE_LIST_ANIM_ATTRS,
              defStyleAttr, defStyleRes);
  try {
    if (a.hasValue(0)) {
              StateListAnimator sla = AnimatorInflater.loadStateListAnimator(context,
                      a.getResourceId(0, 0));
      view.setStateListAnimator(sla);
    }
  } finally {
    a.recycle();
  }
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:16,代码来源:ViewUtilsLollipop.java

示例11: onTranslationZChanged

import android.animation.StateListAnimator; //导入依赖的package包/类
void onTranslationZChanged(float translationZ) {
    StateListAnimator stateListAnimator = new StateListAnimator();
    stateListAnimator.addState(PRESSED_ENABLED_STATE_SET, setupAnimator(ObjectAnimator.ofFloat(this.mView, "translationZ", new float[]{translationZ})));
    stateListAnimator.addState(FOCUSED_ENABLED_STATE_SET, setupAnimator(ObjectAnimator.ofFloat(this.mView, "translationZ", new float[]{translationZ})));
    stateListAnimator.addState(EMPTY_STATE_SET, setupAnimator(ObjectAnimator.ofFloat(this.mView, "translationZ", new float[]{0.0f})));
    this.mView.setStateListAnimator(stateListAnimator);
    if (this.mShadowViewDelegate.isCompatPaddingEnabled()) {
        updatePadding();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:FloatingActionButtonLollipop.java

示例12: ViewHolder

import android.animation.StateListAnimator; //导入依赖的package包/类
ViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);

    if (mContext.getResources().getInteger(R.integer.categories_column_count) == 1) {
        if (card.getLayoutParams() instanceof GridLayoutManager.LayoutParams) {
            GridLayoutManager.LayoutParams params =
                    (GridLayoutManager.LayoutParams) card.getLayoutParams();
            params.leftMargin = 0;
            params.rightMargin = 0;
            params.topMargin = 0;
            params.bottomMargin = 0;

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(0);
            }
        }
    } else {
        setCardViewToFlat(card);
    }

    if (!Preferences.get(mContext).isShadowEnabled()) {
        card.setCardElevation(0f);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StateListAnimator stateListAnimator = AnimatorInflater
                .loadStateListAnimator(mContext, R.animator.card_lift_long);
        card.setStateListAnimator(stateListAnimator);
    }

    card.setOnClickListener(this);
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:34,代码来源:CategoriesAdapter.java

示例13: ViewHolder

import android.animation.StateListAnimator; //导入依赖的package包/类
ViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StateListAnimator stateListAnimator = AnimatorInflater
                .loadStateListAnimator(mContext, R.animator.card_lift_long);
        card.setStateListAnimator(stateListAnimator);
    }
    card.setOnClickListener(this);
}
 
开发者ID:danimahardhika,项目名称:wallpaperboard,代码行数:11,代码来源:WallpaperDetailsCategoryAdapter.java

示例14: setStateListAnimatorFromAttrs

import android.animation.StateListAnimator; //导入依赖的package包/类
static void setStateListAnimatorFromAttrs(View view, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    final Context context = view.getContext();
    final TypedArray a = context.obtainStyledAttributes(attrs, STATE_LIST_ANIM_ATTRS,
            defStyleAttr, defStyleRes);
    try {
        if (a.hasValue(0)) {
            StateListAnimator sla = AnimatorInflater.loadStateListAnimator(context, a.getResourceId(0, 0));
            view.setStateListAnimator(sla);
        }
    } finally {
        a.recycle();
    }
}
 
开发者ID:VyacheslavShmakin,项目名称:GpCollapsingToolbar,代码行数:14,代码来源:ViewUtilsLollipop.java

示例15: setupRaiflat

import android.animation.StateListAnimator; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void setupRaiflat(View view) {
    StateListAnimator stateListAnimator
            = AnimatorInflater.loadStateListAnimator(view.getContext(),
            R.drawable.raiflatbutton_statelistanimator);
    view.setStateListAnimator(stateListAnimator);
}
 
开发者ID:rubensousa,项目名称:RaiflatButton,代码行数:8,代码来源:RaiflatUtils.java


注:本文中的android.animation.StateListAnimator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。