我有一个水平ScrollView,我试图移动,同时设置另一个单独的线性布局的重量。问题是,当视图计算H-Scrollview的权重(或者可能是它计算新的高度时),它会跳到512px的位置并保持在那里。这使得当两个动画一起播放时,scrollview看起来像是在跳跃。我也尝试过单独设置scrollview的重量,它仍然可以。
为水平滚动视图设置动画的代码:
if(currentPlace == 2){
currentPlace--;
if(currentPlace < 0){currentPlace = 0;}
DriverManagerV2.this.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ValueAnimator ani = ValueAnimator.ofInt((int) scroller.getScrollX(), screenWidth *currentPlace);
ani.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) lay.getLayoutParams();
lp.weight = .7f - (.7f*animation.getAnimatedFraction());
lay.requestLayout();
LinearLayout.LayoutParams lp2 = (LinearLayout.LayoutParams) scroller.getLayoutParams();
lp2.weight = 4f + (.7f*animation.getAnimatedFraction());
scroller.requestLayout();
scroller.setScrollX((int) animation.getAnimatedValue());
Log.e("KICKU",""+scroller.getScrollX());
}
});
ani.setDuration(1500);
ani.start();
}
});
}
HorizontalScrollView的XML:
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:fillViewport="true"
android:id="@+id/driver_manager_content"
android:layout_weight="4">
知道怎么解决这个问题吗?
答案 0 :(得分:0)
想出来。这是因为我有一个聚焦的EditText,每当高度改变时它跳转到editText。