Nessuna animation con ViewFlipper?

Sto cercando di utilizzare ViewFlipper per aggiungere un'animation tra le viste, come seguendo un tutorial sul sobject. Tuttavia, sembra che non voglia lavorare. Cambierà le pagine, ma non ho alcuna animation – anche se aggiungo un enorme ritardo a push_left_in.

Ecco il mio onCreate:

  • Perché ContentResolver.requestSync non innesca una sincronizzazione?
  • Come scaricare e salvare un'image in Android
  • Perché la mia app non viene visualizzata su compresse in Google Play?
  • android: capitalizza non funziona
  • Vista calendario per Android GingerBread e prima (API <11)
  • Caricare immagini asincrone in listView
  • @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); viewFlipper = (ViewFlipper)findViewById(R.id.flipper); viewFlipper.setAnimation(AnimationUtils.loadAnimation(this, R.anim.push_left_in)); mapView = (MapView)findViewById(R.id.mapView); mapView.setBuiltInZoomControls(true); } 

    push_left_in viene dai campioni di Google. Ecco l'azione trigger:

     @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.button_map: viewFlipper.setDisplayedChild(0); return true; case R.id.button_conditions_general: viewFlipper.setDisplayedChild(1); return true; (etc) 

    E il mio layout:

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/mainlayout" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <ViewFlipper android:id="@+id/flipper" android:layout_width="fill_parent" android:layout_height="fill_parent"> <view class="com.google.android.maps.MapView" android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="MY_API_KEY" /> <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" android:stretchColumns="1" > <TableRow> <TextView android:id="@+id/field1" android:layout_column="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000" android:textStyle="bold" android:textSize="18px" android:text="@string/field1" > </TextView> <EditText android:text="100" android:id="@+id/field2" android:layout_width="wrap_content" android:layout_height="wrap_content"> </EditText> <TextView android:id="@+id/field3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000" android:textStyle="bold" android:textSize="18px" android:text="%" > </TextView> </TableRow> </TableLayout> </ViewFlipper> </LinearLayout>
    <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/mainlayout" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <ViewFlipper android:id="@+id/flipper" android:layout_width="fill_parent" android:layout_height="fill_parent"> <view class="com.google.android.maps.MapView" android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="MY_API_KEY" /> <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" android:stretchColumns="1" > <TableRow> <TextView android:id="@+id/field1" android:layout_column="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000" android:textStyle="bold" android:textSize="18px" android:text="@string/field1" > </TextView> <EditText android:text="100" android:id="@+id/field2" android:layout_width="wrap_content" android:layout_height="wrap_content"> </EditText> <TextView android:id="@+id/field3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000" android:textStyle="bold" android:textSize="18px" android:text="%" > </TextView> </TableRow> </TableLayout> </ViewFlipper> </LinearLayout> 

    Pensieri?

    2 Solutions collect form web for “Nessuna animation con ViewFlipper?”

    Prova ad impostare le tue animazioni nel file xml.

      <ViewFlipper android:id="@+id/flipper" android:layout_width="fill_parent" android:layout_height="fill_parent" android:inAnimation="@anim/push_left_in"> 

    È necessario impostare separatamente le animazioni in e fuori. Puoi farlo in XML:

     <ViewFlipper android:id="@+id/view_flipper" android:layout_width="match_parent" android:layout_height="match_parent" android:inAnimation="@anim/in_from_right" android:outAnimation="@anim/out_to_left"> 

    o nel codice:

     viewFlipper.setInAnimation(getActivity(), R.anim.in_from_right); viewFlipper.setOutAnimation(getActivity(), R.anim.out_to_left); 
    L'Android è un fan Android di Google, tutto su telefoni Android, Android Wear, Android Dev e applicazioni Android Games e così via.