2017-11-24 1 views
0

Ich habe meinem horizontalen Hintergrund eine blaue Farbe hinzugefügt! Aber anstatt blau, muss ich Ozean wie Hintergrund mit einer kleinen Blase zum Layout hinzufügen. Ich suchte und fand keine Lösung.Wie füge ich Animationen zu einem Hintergrund in der horizontalen Ansicht hinzu?

mein Layout ist:

<LinearLayout android:id="@+id/switcher_view" 
        android:orientation="vertical" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@color/background_light"> 
     <HorizontalScrollView android:id="@+id/switcher_scroller" 
           android:background="@color/blue_200" 
           android:layout_width="match_parent" 
           android:layout_height="match_parent" 
           android:scrollbars="none"> 
      <LinearLayout android:id="@+id/switcher_container" 
          android:orientation="horizontal" 
          android:layout_width="wrap_content" 
          android:layout_height="match_parent"> 
      </LinearLayout> 

     </HorizontalScrollView> 

    </LinearLayout> 

Derzeit sieht es so aus:

enter image description here

Statt statische blau, ich einige Blasen und Animation benötigen, die ein Wasser ähnelt! Änderungen im Layout wie folgt

Antwort

1

Um die Aufgabe sehr simple..first zu machen ..

<FrameLayout android:id="@+id/switcher_view" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <VideoView 
      android:id="@+id/vView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
     <HorizontalScrollView 
      android:id="@+id/switcher_scroller" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:scrollbars="none"> 
      <LinearLayout android:id="@+id/switcher_container" 
       android:orientation="horizontal" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent"> 
      </LinearLayout> 

     </HorizontalScrollView> 

    </FrameLayout> 

und dann ein Video von Ihrer animation..store dass mp4-Datei im Raw-Ordner von Ressourcen machen .. (Schreiben Animation und schlagen wird es etwas hart auf gpu-Rendering) ..

VideoView view = (VideoView)findViewById(R.id.vView); 
String path = "android.resource://" + getPackageName() + "/" + R.raw.video_file; 
view.setVideoURI(Uri.parse(path)); 
view.start(); 

Sie den Abschluss der Video erkennen kann und es mit dem folgenden Code abspielen kann ..

view.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { 
      @Override 
      public void onCompletion(MediaPlayer mp) { 
       view.start(); 
      } 
     }); 
+0

Ja !! Hat funktioniert :) –

Verwandte Themen