0

I have this for animating a RIGHT swipe and it works great:

good swipe

if(direction == RIGHT){
    if(distance < 217) {

        layoutParams.leftMargin = (int) distance + startLeftMargin;
        layoutParams.topMargin = startTopMargin;
        call.setVisibility(View.VISIBLE);
        straddle.setVisibility(View.GONE);
        bet.setVisibility(View.GONE);
        fold.setVisibility(View.GONE);
        ViewGroup.LayoutParams layoutParams = call.getLayoutParams();

        layoutParams.width = (int) getResources().getDisplayMetrics().density * ((int) distance);

            call.setLayoutParams(layoutParams);


    }
<TextView
    android:id="@+id/call"
    android:layout_width="1dp"
    android:layout_height="96dp"
    android:layout_marginStart="68dp"
    android:layout_marginTop="50dp"
    android:background="@drawable/call"
    android:gravity="center|start"
    android:paddingStart="@dimen/default_gap"
    android:text="Call"
    android:textColor="@color/white"
    android:textSize="25sp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"

    />

I have this for animating a LEFT swipe, but it is not working well. As the button moves to the left, the black animation with the word Str. goes to the right. I'd like the black background to stay stationary while the button moves.

bad swipe

} else if(direction == LEFT){
    if(distance < 217) {
        layoutParams.leftMargin = (int) (-distance) + startLeftMargin;
        layoutParams.topMargin = startTopMargin;
        call.setVisibility(View.GONE);
        straddle.setVisibility(View.VISIBLE);
        bet.setVisibility(View.GONE);
        fold.setVisibility(View.GONE);

        ViewGroup.LayoutParams layoutParams = straddle.getLayoutParams();
        layoutParams.width = (int) getResources().getDisplayMetrics().density * (int) distance;

        straddle.setLayoutParams(layoutParams);

    }
<TextView
    android:id="@+id/straddle"
    android:layout_width="1dp"
    android:layout_height="96dp"
    android:layout_marginStart="68dp"
    android:layout_marginTop="50dp"
    android:background="@drawable/straddle"
    android:gravity="center|end"
    android:paddingEnd="@dimen/default_gap"
    android:text="Str."
    android:textColor="@color/white"
    android:textSize="25sp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    />

I really can't figure out what the issue might be, if anyone has any ideas i'd really apreciate it.

2
  • Did you find the solution for this or you're still looking for one. Commented Aug 26, 2024 at 11:36
  • I still haven't figured it out Commented Aug 27, 2024 at 13:11

0

Your Answer

Draft saved
Draft discarded

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.