Skip to content

Commit

Permalink
Fix #162, fix #86: Elevation change as per Material Design spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
vickychijwani committed May 17, 2015
1 parent 2533372 commit 959a6ef
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.melnykov.fab;

import android.animation.AnimatorInflater;
import android.animation.StateListAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.ColorStateList;
Expand Down Expand Up @@ -99,6 +101,11 @@ private void init(Context context, AttributeSet attributeSet) {
mShadow = true;
mScrollThreshold = getResources().getDimensionPixelOffset(R.dimen.fab_scroll_threshold);
mShadowSize = getDimension(R.dimen.fab_shadow_size);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
StateListAnimator stateListAnimator = AnimatorInflater.loadStateListAnimator(context,
R.anim.lift_up);
setStateListAnimator(stateListAnimator);
}
if (attributeSet != null) {
initAttributes(context, attributeSet);
}
Expand Down
25 changes: 25 additions & 0 deletions library/src/main/res/anim-v21/lift_up.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true"
android:state_pressed="true">
<set>
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ"
android:valueTo="@dimen/fab_press_translation_z"
android:valueType="floatType"
/>
</set>
</item>
<item>
<set>
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ"
android:valueTo="0"
android:valueType="floatType"
/>
</set>
</item>
</selector>
3 changes: 2 additions & 1 deletion library/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

<dimen name="fab_scroll_threshold">4dp</dimen>
<dimen name="fab_elevation_lollipop">8dp</dimen>
</resources>
<dimen name="fab_press_translation_z">6dp</dimen>
</resources>

0 comments on commit 959a6ef

Please sign in to comment.