Last active
August 27, 2018 15:37
-
-
Save SeongUgJung/3fbdf7dae793b94f4b2db95ad1068f71 to your computer and use it in GitHub Desktop.
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
class MainViewModel { | |
val scaleAndAlpha = ObservableField<ScaleAlpha>() | |
fun imageClick() { | |
scaleAndAlpha.set(ScaleAlpha(1f,1f)) | |
} | |
} |
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
data class ScaleAlpha(toScale : Float, toAlpha : Float , fromScale : Float = 0f, fromAlpha : Float = 0f) |
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
@BindingAdapter("scaleAndAlpha") | |
fun animateScaleAndAlpha(view : View, scaleAndAlpha : ScaleAlpha) { | |
view.scaleX = scaleAndAlpha.fromScale | |
view.scaleY = scaleAndAlpha.fromScale | |
view.alpha = scaleAndAlpha.fromAlpha | |
view.animate() | |
.scaleX(scaleAndAlpha.toScale) | |
.scaleY(scaleAndAlpha.toScale) | |
.alpha(scaleAndAlpha.toAlpha) | |
.setDuration(300) | |
.start() | |
} |
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
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
> | |
<data> | |
<variable | |
name="vm" | |
type="MainViewModel" | |
/> | |
</data> | |
<ImageView | |
android:layout_width="50dp" | |
android:layout_height="50dp" | |
app:scaleAndAlpha="@{vm.scaleAndAlpha}" | |
android:onClick="@{() -> vm.imageClick()}" | |
/> | |
/layout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment