Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #162, fix #86: Elevation change as per Material Design spec. #172

Merged
merged 1 commit into from
May 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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>