请告诉我应该做什么才能做到这一点,以便淡入发生在“bendView”本身的底部到它自己的顶部,而不是整个视图立即淡入,这就是正在发生的情况这里。我希望视图从下到上慢慢地展现出来。不是从屏幕底部滑入,只是简单的淡入。
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>
我在这个网站和其他资源上搜索了很多,没有提到如何做到这一点。
由于没有人提供帮助,如果将来有人发现此问题,请查看进度条是否适合解决您的问题。