Android ScaleAnimation位于视图上,不移动下面视图的位置
我正在尝试使用以下代码在我的Android应用程序上设置视图高度的动画:Android ScaleAnimation位于视图上,不移动下面视图的位置,android,listview,animation,android-animation,Android,Listview,Animation,Android Animation,我正在尝试使用以下代码在我的Android应用程序上设置视图高度的动画: Animation anim = new ScaleAnimation( 1f, 1f, 1f, 2f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f); anim.setFillAfter(true); anim
Animation anim = new ScaleAnimation(
1f, 1f,
1f, 2f,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f);
anim.setFillAfter(true);
anim.setDuration(500);
mSearchHeader.startAnimation(anim);
这可以很好地为mSearchHeader
的高度设置动画,但是,我的标题下有一个ListView
控件。我的期望是mSearchHeader
的高度扩展将向下推动listview(有效地降低listview高度以补偿较大的页眉高度)
但是,listview的大小保持不变。当标题展开时,如何使listview“收缩”呢?是否还需要向listview添加动画
我的XML是:
<android.support.percent.PercentRelativeLayout
android:id="@+id/main_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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/windowBackground">
<RelativeLayout
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/buttonBackground">
<ListView
android:id="@+id/provider_search_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/search_view" />
....
....
动画
将创建一种动画错觉,只更改视图的矩阵,而不更改实际视图坐标
相反,请使用其他动画API:
mSearchHeader.animate()
.y(100)
.setDuration(500);
这既可以将y
值设置100像素的动画,也可以更改视图
坐标,这最终将影响其下方的列表视图
。动画
将创建动画效果,只更改视图
的矩阵,而不更改实际视图坐标
相反,请使用其他动画API:
mSearchHeader.animate()
.y(100)
.setDuration(500);
这既可以将y
值设置100像素的动画,也可以更改视图
坐标,这最终会影响其下方的列表视图
。这看起来并不是要向下移动列表视图。mSearchHeader
与列表视图重叠。我已经找到了如何使列表视图向下移动的方法,但是会影响性能太糟糕了。不过,我会就此发布另一个问题。这看起来并不是要向下移动listview。mSearchHeader
与listview重叠。我已经找到了如何使listview向下移动的方法,但是,性能太差了。不过,我会发布另一个问题。