-1

状況は、ボタンを押してスコアを上げるときです。スコアを1秒間点滅またはパルスさせたいです。調べてみましたが、まだ答えが見つかりません。番号を画像にする必要がありますか?0を点滅させたい。ボタンコードの例を次に示します。

<TextView
            android:id="@+id/team_a_score"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fontFamily="sans-serif-light"
            android:gravity="center"
            android:paddingBottom="24dp"
            android:text="0"
            android:textColor="#000000"
            android:textSize="56sp" />
4

1 に答える 1

0
Button b1 = findViewById(R.id.my_button);

TextView tv = findViewById(R.id.team_a_score);

Animation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(40); //You can manage the time of the blink with this parameter
anim.setStartOffset(10);
anim.setRepeatMode(Animation.REVERSE);
anim.setRepeatCount(Animation.INFINITE);

b1.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
    tv.startAnimation(anim);
  }
});

お力になれて、嬉しいです。目的の結果が得られるように、期間と値を変更してみてください。

于 2018-02-11T18:10:58.453 に答える