I actually put the image as the background in the view. I want to pin this image, and the cropped image should fill the whole view. I don’t get it right. You can help. here is my code ....
try {setContentView (R.layout.main); ImageView img = (ImageView) findViewById (R.id.img);
Paint paint = new Paint();
paint.setFilterBitmap(true);
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),R.drawable.puli);
int targetWidth = 300;
int targetHeight = 300;
Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight,Bitmap.Config.ARGB_8888);
RectF rectf = new RectF(0, 00, 100, 100);
Canvas canvas = new Canvas(targetBitmap);
Path path = new Path();
path.addRect(rectf, Path.Direction.CW);
canvas.clipPath(path);
canvas.drawBitmap( bitmapOrg,new Rect(0, 0, bitmapOrg.getWidth(), bitmapOrg.getHeight()),
new Rect(0, 0, targetWidth, targetHeight), null);
// = ();
////
//matrix.postScale(100, 133);
//
//Bitmap resizedBitmap = Bitmap.createBitmap(targetBitmap, 0, 0, 100, 133, matrix, true);
////
/* Bitmap */ BitmapDrawable bd = new BitmapDrawable (targetBitmap);
AbsoluteLayout.LayoutParams abs_params =
new AbsoluteLayout.LayoutParams(
30,
40, 0, 0
);
img.setLayoutParams(abs_params);
img.setImageDrawable(bd);
img.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
System.out.println("onTouch");
return false;
}
});
}
catch(Exception e){
System.out.println("Error1 : " + e.getMessage() + e.toString());
}
//my main.xml
: layout_height = "300dp" : layout_width = "300dp" : = "@+ /IMG " : layout_x = "10dip" : layout_y = "50dip"
, , . . . .