本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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();
}
示例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();
}
示例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
{ }
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}