ImageView not 'completely' clearing the bitmap after Transla

Problems with Canvas, OpenGL, etc...

ImageView not 'completely' clearing the bitmap after Transla

Postby gprasanth » Fri Apr 01, 2011 5:43 am

Hi, This problem is troubling me, I have two imageviews in a single row in table. When I click on a image the expected behavior is for it to slide to its right using Translate Animation.

The problem I have is when I click on the first image it moves right and empty slot is formed which is perfectly what I wanted, but when I click this empty spot again the image reappears and does moving right animation again .

Question: I know view object does not change on Translate Animation but why is the bitmap reappearing on the first imageview whenever I reclick it. I would like that to happen only once and then the bitmap stay with the second view forever (totally cleared in firstview). How can I achieve it?

Code:
public class TestCode extends Activity {
Animation transitionAnim = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Bitmap bMap1 = BitmapFactory.decodeResource(getResources(), R.drawable.g1);
Bitmap bMapScaled1 = Bitmap.createScaledBitmap(bMap1, 50, 60, true);

Bitmap bMap2 = BitmapFactory.decodeResource(getResources(), R.drawable.g2);
Bitmap bMapScaled2 = Bitmap.createScaledBitmap(bMap2, 50, 60, true);
try{
TableLayout tableLayout = (TableLayout) findViewById(R.id.tableview);
tableLayout.setClipChildren(false);

TableRow tableRow = new TableRow(this);

ImageView imageView1 = new ImageView(this);
imageView1.setImageBitmap(bMapScaled1);
imageView1.setPadding(1, 1, 1, 1);
imageView1.setOnClickListener(viewClickListener);
tableRow.addView(imageView1);

ImageView imageView2 = new ImageView(this);
imageView2.setImageBitmap(bMapScaled2);
imageView2.setPadding(1, 1, 1, 1);
imageView2.setOnClickListener(viewClickListener);
tableRow.addView(imageView2);

tableLayout.addView(tableRow);
} catch (Exception e){
e.printStackTrace();
}
}

private OnClickListener viewClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
transitionAnim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
transitionAnim.setDuration(1000);
transitionAnim.setFillAfter(true);
v.startAnimation(transitionAnim);
}
};
}
gprasanth
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Apr 01, 2011 5:41 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests