0

J'ai une mise en page avec quelques ImageView comme ceci: enter image description hereComment mettre en coin arrondi sur ImageView tout en utilisant l'animation sur elle

Comme mentionné dans le coin imageView n'est pas reste arrondi lorsqu'il est utilisé l'animation sur elle. Comment le faire arrondir tout en utilisant l'animation dessus?

Code Mise en page:

<TableLayout 
     android:layout_width="wrap_content" 
     android:id="@+id/table1" 
     android:gravity="center" 
     android:layout_height="wrap_content"> 

    <TableRow> 

    <ImageView 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:id="@+id/img1_1" 
     android:background="@drawable/button" 
     android:layout_margin="3dp" 
     /> 

    <ImageView 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:id="@+id/img1_2" 
     android:background="@drawable/button" 
     android:layout_margin="3dp" 
     /> 
    </TableRow> 
    <TableRow> 

    <ImageView 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:id="@+id/img1_3" 
     android:background="@drawable/button" 
     android:layout_margin="3dp" 
    /> 

    <ImageView 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:id="@+id/img1_4" 
     android:background="@drawable/button" 
     android:layout_margin="3dp" 
     /> 
    </TableRow> 
</TableLayout> 

code Java:

ObjectAnimator animator = ObjectAnimator.ofInt(findViewById(id), "backgroundColor", Color.RED, Color.parseColor("#4caf41")).setDuration(5000); 
     Toast.makeText(Game.this, "index" + findViewById(id), Toast.LENGTH_LONG).show(); 
     animator.setEvaluator(new ArgbEvaluator()); 
     animator.start(); 
+0

Essayez d'utiliser Fresco lib ImageView. ça aidera beaucoup! https://github.com/facebook/fresco –

Répondre

0

je résoudre ce problème à chage fait dans cette ligne:

ObjectAnimator animator = ObjectAnimator.ofInt(findViewById(id), "backgroundColor", Color.RED, Color.parseColor("#4caf41")).setDuration(5000); 

comme ceci:

ObjectAnimator animator = ObjectAnimator.ofInt(findViewById(id), "backgroundResource", R.drawable.original_img, R.drawable.org_state).setDuration(2000); 

-à-dire

J'ai mis backgroundResource au lieu de backgroundColor .et définir une image au lieu du code hexcolor.

0

Lorsque l'animation démarre, vous êtes appuyant sur la Imageview. Vous pouvez donc utiliser

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 

    <item android:drawable="@drawable/numpad_button_bg_selected" android:state_selected="true"></item> 
    <item android:drawable="@drawable/numpad_button_bg_pressed" android:state_pressed="true"></item> 
    <item android:drawable="@drawable/numpad_button_bg_normal"></item> 

</selector> 

Utiliser la même image après le bouton pressé .. Peut-être cela vous aidera ..

+0

L'animation démarre sur Create.Sans aucun événement click/press/touched –