我有一个线性布局,当我想以编程方式向其输入TileXY背景图像时,我可以那样做:
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;
我不确定我该怎么做,但是这次我希望LinearLayout中的bitmapDrawable到ScaleType.FitCenter。
我不确定如何做到这一点,如果我没有在BitmapDrawable中放置SetTileModeXY,则MainLinearLayout中的背景将按FitXY进行缩放,但我想在FitCenter
中缩放为什么要在LinearLayout
上将图像设置为背景,当您可以将ImageView
创建为LinearLayout
的子代,且其宽度和高度与父代(LinearLayout
)匹配时,并使用ImageView
。将图像设置为源并使用ScaleType?