• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with image resizing

vasanthj

Lurker
Hello,

I have a TableLayout that dynamically adds TableRow elements during runtime. My current design adds five table rows, and each table row adds five images as shown below:

TableLayout tableLayout = (TableLayout)findViewById(R.id.TableLayout02);
for(int i=0; i<5; i++){
TableRow tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
for(int j=0; j<5; j++){
ImageView imageView = new ImageView(this);
imageView.setImageResource(R.drawable.star);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
tr.addView(imageView);
}
tableLayout.addView(tr);
}

I am using a 96X96 pixel image, and since the width of the five images exceeds the width of the emulator screen, I see only three of them in a row. How do I resize the image without distorting it, and showing all 5 of them in the row?

thanks
 
Back
Top Bottom