Skip to content

Commit 0079422

Browse files
Animation implementiert
1 parent 6c4f630 commit 0079422

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

app/src/main/java/de/eldecker/droid/romanhelden/MainActivity.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
import android.content.Context;
88
import android.content.Intent;
99
import android.content.SharedPreferences;
10+
import android.graphics.drawable.Animatable;
1011
import android.os.Bundle;
1112
import android.util.Log;
1213
import android.view.Menu;
1314
import android.view.MenuInflater;
1415
import android.view.MenuItem;
16+
import android.view.animation.Animation;
17+
import android.view.animation.AnimationUtils;
1518
import android.widget.TextView;
1619
import android.widget.Toast;
1720

@@ -135,11 +138,25 @@ private void neuerName() {
135138
_nameRecord = erzeugeName( genreEnum );
136139
String name = _nameRecord.toString();
137140
_nameTextView.setText( name );
141+
starteAnimation();
138142

139143
namenZaehlerErhoehen();
140144
}
141145

142146

147+
/**
148+
* Tween-Animation auf (neu erzeugten) Namen anwenden.
149+
*/
150+
private void starteAnimation() {
151+
152+
Animation tweenAnimation =
153+
AnimationUtils.loadAnimation( this,
154+
R.anim.tween_animation );
155+
156+
_nameTextView.startAnimation( tweenAnimation );
157+
}
158+
159+
143160
/**
144161
* Zähler für Anzahl der erzeugten Namen in SharedPreferences um 1 erhöhen.
145162
*/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<alpha
5+
android:fromAlpha="0.1"
6+
android:toAlpha="1.0"
7+
android:duration="1500" />
8+
9+
<scale
10+
android:fromXScale="0.1"
11+
android:toXScale="1.0"
12+
android:fromYScale="0.1"
13+
android:toYScale="1.0"
14+
android:pivotX="50%"
15+
android:pivotY="50%"
16+
android:duration="1500" />
17+
18+
</set>

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
android:text="@string/name_beispiel"
3535
android:textStyle="bold"
3636
android:gravity="center_horizontal|center_vertical"
37-
android:textSize="40sp"
37+
android:textSize="50sp"
3838
app:layout_constraintBottom_toBottomOf="parent"
3939
app:layout_constraintEnd_toEndOf="parent"
4040
app:layout_constraintStart_toStartOf="parent"

0 commit comments

Comments
 (0)