Mic*_*sin 5 android android-animation android-coordinatorlayout
假设我的布局类似于:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/bottomIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:src="@drawable/some_image"
app:layout_anchor="@+id/bottomNavigation"
app:layout_anchorGravity="top|center"/>
<some.widget.SomeView
android:id="@+id/bottomView"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
一切都很好,bottomIcon放在上面bottomView.当我尝试翻译bottomView一点时,一切仍然是好的,bottomIcon也被翻译了.
但是,当我尝试bottomView从屏幕上翻译下来时:
public void slideOut(View view) {
view.animate()
.translationY(500) //example constant
.start();
}
//then somewhere call
slideOut(bottomView)
Run Code Online (Sandbox Code Playgroud)
然后bottomView移出屏幕bottomIcon,直到它达到CoordinatorLayout的下限.然后bottomIcon不要向下移动.
bottomIcon即使锚点离开屏幕,我怎样才能实现锚定视图()跟随其锚点('bottomView')?(解决方案越简单越优越好)