Can someone please fix the java code or add something to make it so that the fading in happens from the bottom of the ‘bendView’ itself to it’s own top, instead of the entire view fading in at once, which is what is happening here. I want the view to be revealed slowly from the bottom to the top. Not sliding in from the bottom of the screen just a simple fading in.
MainActivity.java:
package org.kaustav.testing;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private View bendView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bendView = findViewById(R.id.bendView);
ObjectAnimator animator = ObjectAnimator.ofFloat(bendView, "alpha", 1.0f, 0.0f);
animator.setDuration(2000);
animator.setRepeatMode(ValueAnimator.REVERSE);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.start();
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="#F8F7F7"
tools:context=".MainActivity">
<View
android:id="@+id/bendView"
android:layout_width="16dp"
android:layout_height="226dp"
android:background="#000000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.136"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.499" />
</androidx.constraintlayout.widget.ConstraintLayout>
I have searched a lot on this website and other resources, there is no mention of how to do this.