Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Animation - Need to move to a certain position
    primarykey
    data
    text
    <p>I have a problem!</p> <p>First. I need to animate a card, moving from its original position and land on top of another predefined imageview (Representing the stack of cards at a cardtable)</p> <pre><code> public static ImageView REFERENCE_IMAGE_FOR_ANIMATION; REFERENCE_IMAGE_FOR_ANIMATION = (ImageView) findViewById(R.id.cardpile); public void deckButtonOnClick(View v) { ImageView imageView = new ImageView(getApplicationContext()); imageView.setImageResource(DECK.takeCard()); imageView.setAdjustViewBounds(true); imageView.setLayoutParams(PARAMS); imageView.setTag("0"); imageView.setOnClickListener(new MyOnClickListener()); ((LinearLayout) findViewById(R.id.innerLinearLayout)) .addView(imageView); } </code></pre> <p>My code for MyOnClickListener is the following:</p> <pre><code>public class MyOnClickListener{ Animation standardPosition = new TranslateAnimation(0, 0, 0, -25f); @Override public void onClick(View v) { Animation standardPosition; Animation risedPositionAndChosen; if (v.getTag().toString().equalsIgnoreCase("0")) { standardPosition = new TranslateAnimation(0, 0, 0, -25f); standardPosition.setDuration(400); standardPosition.setFillAfter(true); v.setTag("1"); v.startAnimation(standardPosition); } else if (v.getTag().toString().equalsIgnoreCase("1")) { risedPositionAndChosen = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_PARENT, Game.REFERENCE_IMAGE_FOR_ANIMATION.getRight() - v.getRight(), Animation.RELATIVE_TO_SELF, 0,Animation.RELATIVE_TO_PARENT, -Game.REFERENCE_IMAGE_FOR_ANIMATION.getTop()); risedPositionAndChosen.setDuration(400); risedPositionAndChosen.setFillAfter(true); v.setTag("0"); v.startAnimation(risedPositionAndChosen); } else if (v.getTag().toString().equalsIgnoreCase("2")) { } ((View) v.getParent()).invalidate(); } </code></pre> <p>}</p> <p>It is the first "else if" statement in my OnClickListener that i somehow need to change. The <code>REFERENCE_IMAGE_FOR_ANIMATION = (ImageView) findViewById(R.id.cardpile);</code> is the card i need to "land on".</p> <p>secondly: My layout for the game screen contains a nested scrollview with a linearlayout inside. When the animation starts the card sort of "slips under" the layouts higher in the hierarchy. If someone could tell me what i had to do inorder for it to "float on top" i'd really appreciate it!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload