/** 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);
}
ViewUtilsLollipop.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:iosched
作者:
评论列表
文章目录