2016-06-15 4 views
0

Das ist meine Situation. Ich habe eine Bildansicht, die als Hintergrund dient, und eine zweite Bildansicht, die darüber platziert wird. In der Bildansicht, die als Hintergrund verwendet wird, dreht es sich so, dass ich möchte, dass die Bildansicht darauf der Rotationsumsetzung folgt, die ausgeführt wird. Wie würde ich das tun? Im Wesentlichen möchte ich die zweite Bildansicht verankern, wenn die andere Bildansicht gedreht wird. Dies ist der Code, den ich bisher habe:Android Imageview ontop voneinander mit Rotation

  <RelativeLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="100dp" 
        android:clipChildren="false" 
        android:orientation="horizontal"> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="65dp" 
         android:layout_marginTop="-20dp" 
         android:id="@+id/unit" 
         android:src="@drawable/unit"/> 
        <ImageView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="80dp" 
         android:id="@+id/button" 
         android:src="@drawable/button" 
         /> 
        /> 

    private void rotate(int rotation) { 
    button.setTranslationX(1); 
    button.setTranslationY(-1); 
    if(rotation > 35) { 
     rotation = 35; 
    } 
    if(rotation < 0) { 
     rotation = 0; 
    } 
    Matrix matrix = new Matrix(); 
    unit.setScaleType(ImageView.ScaleType.MATRIX); 
    matrix.postRotate(rotation, 
    unit.getDrawable().getBounds().width(),  unit.getDrawable().getBounds().height()); 
    unit.setImageMatrix(matrix); 
} 

Antwort

0

Haben Sie versucht, das relative Layout stattdessen zu drehen?

+0

Ich möchte das Bild nicht über dem anderen Bild drehen, weil das Bild gefällt, es wird auch gedreht. Ich brauche nur die Übersetzung mit der gleichen Ausrichtung. – yetanotherposter