Created
November 3, 2018 19:41
-
-
Save alexmprog/305ecbec52f97073c9edad433aceb415 to your computer and use it in GitHub Desktop.
Elevation animation for scrolled views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <item android:state_selected="true"> | |
| <objectAnimator | |
| android:duration="200" | |
| android:propertyName="elevation" | |
| android:valueTo="6dp" | |
| android:valueType="floatType" /> | |
| </item> | |
| <item> | |
| <objectAnimator | |
| android:duration="200" | |
| android:propertyName="elevation" | |
| android:valueTo="0dp" | |
| android:valueType="floatType" /> | |
| </item> | |
| </selector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <FrameLayout | |
| android:id="@+id/header" | |
| android:layout_width="match_parent" | |
| android:layout_height="52dp" | |
| android:background="#ffffff" | |
| android:stateListAnimator="@animator/toolbar_elevation"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scroll_view.setOnScrollChangeListener { _, _, _, _, _ -> | |
| header.isSelected = scroll_view.canScrollVertically(-1) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment