2017-06-06 7 views
0

Ich habe eine Bildansicht, die eine Animation hat. Wenn das Bild jedoch verschoben wird, geht es hinter sein Layout, wie Sie in diesem Bild sehen können: my imageAndroid: ImageView ist unter dem Layout

Ich möchte, dass diese Bildansicht vor dem Layout ist. Ich habe versucht mit yourView.bringToFront();, aber auf diese Weise ist die Bildansicht vor den anderen Ansichten, nicht das Layout. Hier

ist die xml:

  <LinearLayout 
      android:id="@+id/layoutComponentiNemico" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:orientation="vertical"> 

      <RelativeLayout 
       android:id="@+id/layoutContenitoreImmagineNemico" 
       android:layout_width="50dp" 
       android:layout_height="0dp" 
       android:layout_gravity="center" 
       android:layout_weight="5"> 

       <ImageView 
        android:id="@+id/immagineNemico" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@drawable/anziano"/> 
      </RelativeLayout> 

      <ImageView 
       android:id="@+id/immaginePiattaformaNemico" 
       android:layout_width="150dp" 
       android:layout_height="0dp" 
       android:layout_gravity="center" 
       android:layout_weight="1" 
       android:background="@drawable/piattaformaritagliata"/> 

     </LinearLayout> 

Also mein Imageview soll "erlischt" aus dem relativen Layout während der Animation.

Die Animation:

immagineNemico.clearAnimation(); 
    TranslateAnimation mAnimation = new TranslateAnimation(
      TranslateAnimation.RELATIVE_TO_PARENT, 0f, 
      TranslateAnimation.RELATIVE_TO_PARENT, -0.4f, 
      TranslateAnimation.RELATIVE_TO_PARENT, 0f, 
      TranslateAnimation.RELATIVE_TO_PARENT, 0.1f); 
    mAnimation.setDuration(1000); 
    mAnimation.setRepeatCount(1); 
    mAnimation.setRepeatMode(Animation.REVERSE); 
    mAnimation.setInterpolator(new DecelerateInterpolator()); 
    immagineNemico.setAnimation(mAnimation); 

Antwort

0

Könnte es sein, dass Sie die Animation zu @id/layoutContenitoreImmagineNemico statt @id/immaginePiattaformaNemico bewerben?

Bitte zeigen Sie uns Ihren Animationscode.

+0

Ich aktualisierte die Frage – Curio

+0

@Curio Sie können die Animation nicht direkt auf die Bildansicht anwenden, um zu erreichen, was Sie wollen. Das ImageView befindet sich innerhalb des Layouts. Wenn es die Grenzen des Layouts verlässt, verschwindet das Bild. Versuchen Sie, die Animation auf das Layout selbst anzuwenden und sehen Sie, ob das funktioniert. –

+0

Muss ich also die Animation sowohl auf die Bildansicht als auch auf das Layout anwenden? – Curio

Verwandte Themen