2017-03-22 76 views
1

我有2个视图(一个按钮和一个滑块),一个在另一个之上,我动画的框架中的较低的一个,我希望另一个视图也减少相同的数量。我的问题是,较低视图用于剪切顶视图的位置。 (见图)。这两个动画都是由视图模型属性更改触发的。动画2视图一起隐藏其中一个视图是

TimeView.Animate().TranslationYBy(ViewModel.IsShowingEmployees ? -TimeView.Height : TimeView.Height); 
MyPositionButton.Animate().TranslationYBy(ViewModel.IsShowingEmployees ? -TimeView.Height : TimeView.Height); 

动画之前: enter image description here

动画后: enter image description here

如何获得较低的视图停止剪裁上吗?我试图改变视图的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> 

回答

0

上的“显示布局界限”开关后,OP发现他是动画的Button本身,而不是RelativeLayout。在动画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> 
+0

对不起,我忘了在OP中提到这是我尝试的解决方案之一,它得到了同样的结果。 – Sevren

+0

您可以在“显示布局界限”模式上共享屏幕截图吗? – azizbekian

+0

这是我需要的微调。当获得带有“ShowLayoutBounds”的SS时,我注意到我正在为按钮本身设置动画,而不是它的继续布局,所以布局剪裁了按钮。我只是让它的相对布局动画化,而且一切都很好。 \ m /(><)\ m /用这个信息更新你的文章,我会让它成为被接受的答案。谢谢。 – Sevren

相关问题