I have a linear layout that when i want programmatically to enter a TileXY background image to it i can do it that way:
ImageButton.SetImageBitmap(BitmapFactory.DecodeFile(Button1ImageURI));
Bitmap temp = BitmapFactory.DecodeFile(Button1ImageURI);
BitmapDrawable bitmapDrawable = new BitmapDrawable(Resources, temp);
bitmapDrawable.SetTileModeXY(Shader.TileMode.Repeat, Shader.TileMode.Repeat);
MainLinearLayout.Background = bitmapDrawable;
I'm not sure how i can do the same but this time i want the bitmapDrawable to ScaleType.FitCenter in the LinearLayout.
I'm not sure how i can do that, if i don't put a SetTileModeXY in the BitmapDrawable, Background in MainLinearLayout is scaled with FitXY, but i want to be scaled in FitCenter
Why you want to set image as background on the LinearLayout
, when you can create ImageView
as a child of the LinearLayout
with width and height that match the parent(LinearLayout
), and use the benefits of the ImageView
. Setting the image as source and use the ScaleType?