Android 同时设置两个视图的动画将隐藏另一个视图所在的位置

Android 同时设置两个视图的动画将隐藏另一个视图所在的位置,android,animation,xamarin.android,android-animation,Android,Animation,Xamarin.android,Android Animation,我有两个视图(一个按钮和一个滑动条),一个在另一个上方,我正在为较低的一个设置帧外动画,我希望另一个视图也设置相同数量的动画。我的问题是,下视图用于剪裁顶视图的位置。(见图片)。这两个动画都是由视图模型属性更改触发的 TimeView.Animate().TranslationYBy(ViewModel.IsShowingEmployees ? -TimeView.Height : TimeView.Height); MyPositionButton.Animate().TranslationY

我有两个视图(一个按钮和一个滑动条),一个在另一个上方,我正在为较低的一个设置帧外动画,我希望另一个视图也设置相同数量的动画。我的问题是,下视图用于剪裁顶视图的位置。(见图片)。这两个动画都是由视图模型属性更改触发的

TimeView.Animate().TranslationYBy(ViewModel.IsShowingEmployees ? -TimeView.Height : TimeView.Height);
MyPositionButton.Animate().TranslationYBy(ViewModel.IsShowingEmployees ? -TimeView.Height : TimeView.Height);
动画之前:

动画之后:

如何使下部视图停止剪裁上部视图?我试图改变视图的Z和TransitionZ属性,以确保按钮高于栏。我还尝试将该条的可见性设置为动画完成时的可见性。此外,我还尝试使用TranslateAnimation,以便可以控制填充属性。这些东西都不管用

下面是axml的一个例子

<RelativeLayout
    android:id="@+id/map_area_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_toLeftOf="@id/under_list_view">
    <RelativeLayout
        android:id="@+id/map_container_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <RelativeLayout
        android:id="@+id/time_view"
        android:layout_width="300dp"
        android:layout_height="44dp"
        android:background="#ddffffff"
        android:layout_alignParentBottom="true">
        <TextView
            android:id="@+id/time_text_view"
            android:layout_height="match_parent"
            android:layout_width="wrap_content"
            android:text="4:56PM"
            android:textColor="@color/gray_dark"
            android:textSize="18dp"
            android:gravity="center_vertical"
            android:layout_marginLeft="10dp" />
        <SeekBar
            android:id="@+id/time_seek_bar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:max="1440"
            android:progress="700"
            android:progressDrawable="@drawable/custom_scrubber_progress"
            android:thumb="@drawable/custom_scrubber_control"
            android:secondaryProgress="0"
            android:layout_alignParentRight="true"
            android:layout_toRightOf="@+id/time_text_view" />
    </RelativeLayout>
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/time_view"
        android:layout_alignParentLeft="true"
        android:layout_margin="5dp">
        <ImageButton
            android:id="@+id/my_location_button"
            android:layout_height="50dp"
            android:layout_width="50dp"
            android:background="@drawable/ek_fab_button_ripple_white"
            android:src="@drawable/ic_my_location_24p"
            android:tint="@color/gray_dark" />
    </RelativeLayout>
</RelativeLayout>

打开“显示布局边界”后,OP发现他正在设置
按钮本身的动画,而不是
相对动画。设置
RelativeLayout
动画后,不会发生剪辑

旧答案

更改
RelativeLayout
s的位置,以便在下面声明一个带有
ImageButton
的按钮,另一个带有
SeekBar
的按钮。在这种情况下,
ImageButton
将绘制在
SeekBar

<RelativeLayout
    android:id="@+id/map_area_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_toLeftOf="@id/under_list_view">
    <RelativeLayout
        android:id="@+id/map_container_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <RelativeLayout
        android:id="@+id/time_view"
        android:layout_width="300dp"
        android:layout_height="44dp"
        android:background="#ddffffff"
        android:layout_alignParentBottom="true">
        <TextView
            android:id="@+id/time_text_view"
            android:layout_height="match_parent"
            android:layout_width="wrap_content"
            android:text="4:56PM"
            android:textColor="@color/gray_dark"
            android:textSize="18dp"
            android:gravity="center_vertical"
            android:layout_marginLeft="10dp" />
        <SeekBar
            android:id="@+id/time_seek_bar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:max="1440"
            android:progress="700"
            android:progressDrawable="@drawable/custom_scrubber_progress"
            android:thumb="@drawable/custom_scrubber_control"
            android:secondaryProgress="0"
            android:layout_alignParentRight="true"
            android:layout_toRightOf="@+id/time_text_view" />
    </RelativeLayout>
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/time_view"
        android:layout_alignParentLeft="true"
        android:layout_margin="5dp">
        <ImageButton
            android:id="@+id/my_location_button"
            android:layout_height="50dp"
            android:layout_width="50dp"
            android:background="@drawable/ek_fab_button_ripple_white"
            android:src="@drawable/ic_my_location_24p"
            android:tint="@color/gray_dark" />
    </RelativeLayout>
</RelativeLayout>

打开“显示布局边界”后,OP发现他正在设置
按钮本身的动画,而不是
相对动画。设置
RelativeLayout
动画后,不会发生剪辑

旧答案

更改
RelativeLayout
s的位置,以便在下面声明一个带有
ImageButton
的按钮,另一个带有
SeekBar
的按钮。在这种情况下,
ImageButton
将绘制在
SeekBar

<RelativeLayout
    android:id="@+id/map_area_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_toLeftOf="@id/under_list_view">
    <RelativeLayout
        android:id="@+id/map_container_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <RelativeLayout
        android:id="@+id/time_view"
        android:layout_width="300dp"
        android:layout_height="44dp"
        android:background="#ddffffff"
        android:layout_alignParentBottom="true">
        <TextView
            android:id="@+id/time_text_view"
            android:layout_height="match_parent"
            android:layout_width="wrap_content"
            android:text="4:56PM"
            android:textColor="@color/gray_dark"
            android:textSize="18dp"
            android:gravity="center_vertical"
            android:layout_marginLeft="10dp" />
        <SeekBar
            android:id="@+id/time_seek_bar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:max="1440"
            android:progress="700"
            android:progressDrawable="@drawable/custom_scrubber_progress"
            android:thumb="@drawable/custom_scrubber_control"
            android:secondaryProgress="0"
            android:layout_alignParentRight="true"
            android:layout_toRightOf="@+id/time_text_view" />
    </RelativeLayout>
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/time_view"
        android:layout_alignParentLeft="true"
        android:layout_margin="5dp">
        <ImageButton
            android:id="@+id/my_location_button"
            android:layout_height="50dp"
            android:layout_width="50dp"
            android:background="@drawable/ek_fab_button_ripple_white"
            android:src="@drawable/ic_my_location_24p"
            android:tint="@color/gray_dark" />
    </RelativeLayout>
</RelativeLayout>


对不起,我忘了在OP中提到这是我尝试过的解决方案之一,它得到了相同的结果。你能在打开“显示布局边界”模式的情况下共享一个屏幕截图吗?这就是我需要的提示。在打开“ShowLayoutBounds”的SS时,我注意到我正在设置按钮本身的动画,而不是它的连续布局,因此布局正在剪辑按钮。我只是让它动画的相对布局,而不是一切都很好\m/(>@neurs,已更新。在这种情况下,“显示布局边界”可能与您在一起:-)抱歉,我忘了在OP中提到这是我尝试过的解决方案之一,它得到了相同的结果。您可以在打开“显示布局边界”模式的情况下共享屏幕截图吗?这是我需要的提示。在打开“ShowLayoutBounds”的SS时,我注意到我正在设置按钮本身的动画,而不是它的连续布局,因此布局正在剪辑按钮。我只是让它动画的相对布局,而不是一切都很好\m/(>@neurs,已更新。在这种情况下,您是否可以使用“show layout bound”: