I have this for animating a RIGHT swipe and it works great:
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.
} 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.
-
Did you find the solution for this or you're still looking for one.Deepak J– Deepak J2024年08月26日 11:36:19 +00:00Commented Aug 26, 2024 at 11:36
-
I still haven't figured it outOPerator– OPerator2024年08月27日 13:11:08 +00:00Commented Aug 27, 2024 at 13:11
default