KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am currently developing an app that goes through a story. The story contains "scenes" which contain multiple JPEG and PNG files that are displayed via ImageViews. I create the ImageView and add at it to the layout via the following function: private ImageView newImage(Show show) { ImageView iv = new ImageView(this); String filePath = comin.generateFilePath(show); Log.i(TAG, "newImage, filePath = " + filePath + " id = " + show.id); WeakReference<Bitmap> bmp = new WeakReference<Bitmap>(scaleBitmap(filePath)); //added 4/1/13 //Bitmap bmp = scaleBitmap(filePath); Log.i(TAG, "newImage, width = " + bmp.get().getWidth() + ", height = " + bmp.get().getHeight()); iv.setImageBitmap(bmp.get()); iv.setScaleType(ImageView.ScaleType.FIT_XY); iv.setId(show.id); //set visibility if (show.visible) iv.setVisibility(View.VISIBLE); else iv.setVisibility(View.INVISIBLE); //set dimensions int width = (app.getWidth() * show.dimX) / 100; int height = (app.getHeight() * show.dimY) / 100; RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(width, height); iv.setLayoutParams(rlp); return iv; } Once the scene is over, I then clear all of the ImageViews except for one which has no image and only serves to listen for touch events. private void clearScene(boolean clearTouch) { RelativeLayout parent = (RelativeLayout) findViewById(R.id.relative_layout); logMemory("clearScene, START"); int count = parent.getChildCount(); for (int a = count - 1; a >= 0; a--) { int id = parent.getChildAt(a).getId(); String message = "clearScene id = " + id + ", count = " + count + ", a = " + a; if (id == TOUCH_VIEW_ID && !clearTouch) { message = message + ", ignore touch screen view"; } else { unbindView(parent.getChildAt(a));
Tags (comma-separated)
Save Edits
Cancel