что я в основном хочу, чтобы круговые кнопки исчезали при нажатии переключателя и постепенно возвращались к тому, что было, когда переключатель включен. Я нашел способ затухания анимации, но я не могу вернуть его снова после того, как он станет прозрачным.
Мой код
new Thread(new Runnable() {
@Override
public void run() {
aSwitch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (aSwitch.isChecked()) {
Animation anim = new AlphaAnimation(1.0f,0.0f);
anim.setDuration(800);
changer.startAnimation(anim);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
database.child("Lock Status").addValueEventListener(listener);
checklive = true;
PerformCommands();
}
@Override
public void onAnimationEnd(Animation animation) {
changer.setBackgroundColor(Color.TRANSPARENT);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
System.out.println("Switch On");
}
else{
count = 0;
checklive = false;
System.out.println("Switch Off");
changer.setOnCheckedChangeListener(null);
changer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked){
Toast.makeText(getActivity(), "Please go live first to unlock and lock door", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(getActivity(), "Please go live first to unlock and lock door", Toast.LENGTH_SHORT).show();
}
}
});
text.setText("Waiting to go live....");
database.child("Lock Status").removeEventListener(listener);
}
}
});
}
}).start();
Моя кнопка XML
<ToggleButton
android:id="@+id/button5"
android:layout_width="315dp"
android:layout_height="315dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="8dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/circle_button"
android:text=""
android:textOff=""
android:textOn=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.944"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.702" />
Кнопка круг XML
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<size android:height="283dp" android:width="283dp"/>
<solid android:color="#666c68"/>
<corners android:radius="278dp"/>
Если бы кто-нибудь мог помочь мне с переходом, я был бы очень благодарен. Спасибо