I have a Horizontal ScrollView that I am trying to get to move while at the same time setting the weight of another, separate Linear Layout. The problem is when the view is calculating the weight (or maybe its just when it calculates the new height) of the H-Scrollview it jumps to position 512px and stays there. This makes the scrollview look like it is jumping when the two animations are played together. I have also tried setting just the weight of the scrollview alone and it still does it.
Code that animates the Horizontal Scroll view:
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();
}
});
}
And the XML for the HorizontalScrollView:
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:fillViewport="true"
android:id="@+id/driver_manager_content"
android:layout_weight="4">
Any idea how to fix this?
Aucun commentaire:
Enregistrer un commentaire