Habe ein paar Transition Animationen in meiner App. Die Animation läuft auf meinem Galaxy Nexus super flüssig, ohne irgendwelche Lags irgendeiner Art. Am Motorola DEFY auch keine Probleme!
Als ich heute die App auf einem Samsung Galaxy S, Samsung Galaxy S2 probiert hatte, musste ich feststellen das die Animation fast überhaupt nicht funktioniert. Das heißt Riesen-Lags.
Versteh ich irgendwie nicht da ja ein Samsung Galaxy S2 ja nicht soviel schlechter ist als mein Nexus - was die Performance angeht!
Hab das ganze dann noch auf meinem alten HTC Magic probiert. Dort liefen die Animationen ähnlich wie auf dem Samsung Galaxy S2 - Wie ist das zu verstehen?
Ich vermute das irgendetwas an meinen Animationen "falsch" programmiert ist, und nur Android 4.0 damit klar kommt?
Hier die Methode in der ich animiere, es wird damit 6 mal die MAIN_CELL.xml bewegt (rechts und links aus dem Bildschirm raus):
ON BUTTON ANIMATION:
2 int duration) {
3 main_cell1 = (FrameLayout) findViewById(R.id.main_cell1);
4 main_cell2 = (FrameLayout) findViewById(R.id.main_cell2);
5 main_cell3 = (FrameLayout) findViewById(R.id.main_cell3);
6 main_cell4 = (FrameLayout) findViewById(R.id.main_cell4);
7 main_cell5 = (FrameLayout) findViewById(R.id.main_cell5);
8 main_cell6 = (FrameLayout) findViewById(R.id.main_cell6);
9 this.first = first2;
10
11 main_cell1.setDrawingCacheEnabled(true);
12 main_cell2.setDrawingCacheEnabled(true);
13 main_cell3.setDrawingCacheEnabled(true);
14 main_cell4.setDrawingCacheEnabled(true);
15 main_cell5.setDrawingCacheEnabled(true);
16 main_cell6.setDrawingCacheEnabled(true);
17
18 Animation a = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
19 Animation.RELATIVE_TO_SELF, 0);
20 a.reset();
21
22 a = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
23 (-main_cell1.getWidth()), Animation.RELATIVE_TO_SELF, 0);
24 a.setDuration(duration);
25 a.setFillAfter(true);
26 // main_cell1.clearAnimation();
27 main_cell1.startAnimation(a);
28 if (first != 1) {
29 a.setStartOffset(offset);
30 }
31 a.reset();
32
33 a = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
34 -main_cell3.getWidth(), Animation.RELATIVE_TO_SELF, 0);
35 a.setDuration(duration);
36 a.setFillAfter(true);
37 // main_cell3.clearAnimation();
38 main_cell3.startAnimation(a);
39 if (first != 3) {
40 a.setStartOffset(offset);
41 }
42 a.reset();
43
44 a = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
45 -main_cell5.getWidth(), Animation.RELATIVE_TO_SELF, 0);
46 a.setDuration(duration);
47 a.setFillAfter(true);
48 // main_cell5.clearAnimation();
49 main_cell5.startAnimation(a);
50 if (first != 5) {
51 a.setStartOffset(offset);
52 }
53 a.reset();
54
55 a = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
56 main_cell2.getWidth(), Animation.RELATIVE_TO_SELF, 0);
57 a.setDuration(duration);
58 a.setFillAfter(true);
59 // main_cell2.clearAnimation();
60 main_cell2.startAnimation(a);
61 if (first != 2) {
62 a.setStartOffset(offset);
63 }
64 a.reset();
65 if (first != 6) {
66 a = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
67 main_cell4.getWidth(), Animation.RELATIVE_TO_SELF, 0);
68 a.setDuration(duration);
69 a.setFillAfter(true);
70 // main_cell4.clearAnimation();
71 main_cell4.startAnimation(a);
72 if (first != 4) {
73 a.setStartOffset(offset);
74 }
75 a.reset();
76
77 a = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
78 main_cell6.getWidth(), Animation.RELATIVE_TO_SELF, 0);
79 a.setDuration(duration);
80 a.setFillAfter(true);
81 // main_cell6.clearAnimation();
82 main_cell6.startAnimation(a);
83 if (first != 6) {
84 a.setStartOffset(offset);
85 }
86 a.reset();
87 } else {
88
89 a = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
90 main_cell6.getWidth(), Animation.RELATIVE_TO_SELF, 0);
91 a.setDuration(duration);
92 a.setFillAfter(true);
93 // main_cell6.clearAnimation();
94 main_cell6.startAnimation(a);
95 if (first != 6) {
96 a.setStartOffset(offset);
97 }
98 a.reset();
99 a = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
100 main_cell4.getWidth(), Animation.RELATIVE_TO_SELF, 0);
101 a.setDuration(duration);
102 a.setFillAfter(true);
103 // main_cell4.clearAnimation();
104 main_cell4.startAnimation(a);
105 if (first != 4) {
106 a.setStartOffset(offset);
107 }
108 a.reset();
109 }
110 a.setAnimationListener(new MyListener());
111 }
MAIN_CELL.xml:
2 android:id="@+id/cell1Frame"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:layout_weight="1" >
6
7 <Button
8 android:id="@+id/cell1_button"
9 android:layout_width="fill_parent"
10 android:layout_height="fill_parent"
11 android:layout_weight="1"
12 android:background="@null"
13 android:onClick="onButton1"
14 android:text="" />
15
16 <LinearLayout
17 android:id="@+id/linearLayout1"
18 android:layout_width="fill_parent"
19 android:layout_height="fill_parent"
20 android:layout_weight="1"
21 android:orientation="vertical" >
22
23 <LinearLayout
24 android:id="@+id/linearLayout2"
25 android:layout_width="fill_parent"
26 android:layout_height="fill_parent"
27 android:layout_weight="1"
28 android:orientation="horizontal" >
29
30 <ImageButton
31 android:id="@+id/button1"
32 android:layout_width="fill_parent"
33 android:layout_height="fill_parent"
34 android:layout_marginBottom="0.5dp"
35 android:layout_marginLeft="5dp"
36 android:layout_marginRight="0.5dp"
37 android:layout_marginTop="5dp"
38 android:layout_weight="1"
39 android:background="@drawable/bluebutton"
40 android:clickable="false"
41 android:gravity="center_vertical|center_horizontal"
42 android:scaleType="center"
43 android:src="@drawable/homepage"
44 android:text="" />
45
46 <FrameLayout
47 xmlns:android="http://schemas.android.com/apk/res/android"
48 android:id="@+id/frameLayoutX1"
49 android:layout_width="fill_parent"
50 android:layout_height="fill_parent"
51 android:layout_marginBottom="0.5dp"
52 android:layout_marginLeft="0.5dp"
53 android:layout_marginRight="5dp"
54 android:layout_marginTop="5dp"
55 android:layout_weight="1"
56 android:clickable="false" >
57
58 <Button
59 android:id="@+id/button2"
60 android:layout_width="fill_parent"
61 android:layout_height="fill_parent"
62 android:layout_weight="1"
63 android:background="@drawable/bluebutton"
64 android:clickable="false"
65 android:text="" />
66
67 <TextView
68 style="@style/main_text"
69 android:text="Homepage" >
70 </TextView>
71 </FrameLayout>
72 </LinearLayout>
73
74 <LinearLayout
75 android:id="@+id/linearLayout3"
76 android:layout_width="fill_parent"
77 android:layout_height="fill_parent"
78 android:layout_weight="1"
79 android:clickable="false"
80 android:orientation="horizontal" >
81
82 <Button
83 android:id="@+id/buttonx1"
84 android:layout_width="fill_parent"
85 android:layout_height="fill_parent"
86 android:layout_marginBottom="5dp"
87 android:layout_marginLeft="5dp"
88 android:layout_marginRight="0.5dp"
89 android:layout_marginTop="0.5dp"
90 android:layout_weight="1"
91 android:background="@drawable/bluebutton"
92 android:clickable="false"
93 android:text="" />
94
95 <ImageButton
96 android:id="@+id/buttonx2"
97 android:layout_width="fill_parent"
98 android:layout_height="fill_parent"
99 android:layout_marginBottom="5dp"
100 android:layout_marginLeft="0.5dp"
101 android:layout_marginRight="5dp"
102 android:layout_marginTop="0.5dp"
103 android:layout_weight="1"
104 android:background="@drawable/bluebutton"
105 android:clickable="false"
106 android:gravity="center_vertical|center_horizontal"
107 android:scaleType="center"
108 android:src="@drawable/pfeil"
109 android:text="" />
110 </LinearLayout>
111 </LinearLayout>
112
113</FrameLayout>
Hoffe ihr könnt mir da helfen,
kirmac09

