I want to create an imagebutton, but the image doesn’t fill the imagebutton. The image has the same dimensions as the imagebutton.
The imagebutton has the correct dimension, it seems like the imagebutton has an padding?!
I tried most of the scaletypes.
My code:
ImageButton ib = new ImageButton(Context);
AbsoluteLayout.LayoutParams lp = new AbsoluteLayout.LayoutParams((int)getWidth(3), (int)rowHeight, (int)offsetValue, (int)(offsetRow+row*rowHeight));
Stream bitmap = act.Assets.Open("somefolder/" + name + ".gif");
Bitmap bMap = Android.Graphics.BitmapFactory.DecodeStream(bitmap);
bMap = Bitmap.CreateScaledBitmap(bMap, (int)getWidth(3), (int)rowHeight, false);
ib.SetScaleType(ImageButton.ScaleType.FitXy);
ib.SetAdjustViewBounds(true);
ib.SetImageBitmap(bMap);
bitmap = null;
bMap = null;
ib.LayoutParameters = lp;
layout.AddView(ib);
Yeah it has a padding or something like that, I wanted to create a button in an EditText in order to allow the user to make a password viewable and had the same issue… and haven’t found a solution for this until now.
For what you are trying I recomment using an ImageView and make it clickable than you have the same functionality, just like an imagebutton,