Drawable 被拉伸以适应视图
Drawable gets stretched to fit the view
我正在尝试将位图 Drawable 设置为这样的背景,root.setBackground(bitmapDrawable);
,我已将其边界设置为 1080 宽 x 300 高,但它会不断拉伸以适应整个背景。有什么办法可以避免这种情况吗?这就是我创建 BitmapDrawable
BitmapDrawable bitmapDrawable= new BitmapDrawable(getResources(), bmp1);
的方式
我相信 BitmapDrawable
的默认 Gravity
是 FILL
。尝试将 Gravity
设置为 CENTER
:
bitmapDrawable.setGravity(Gravity.CENTER);
我正在尝试将位图 Drawable 设置为这样的背景,root.setBackground(bitmapDrawable);
,我已将其边界设置为 1080 宽 x 300 高,但它会不断拉伸以适应整个背景。有什么办法可以避免这种情况吗?这就是我创建 BitmapDrawable
BitmapDrawable bitmapDrawable= new BitmapDrawable(getResources(), bmp1);
我相信 BitmapDrawable
的默认 Gravity
是 FILL
。尝试将 Gravity
设置为 CENTER
:
bitmapDrawable.setGravity(Gravity.CENTER);