android:image strech unit should multiply scale

This commit is contained in:
pengfei.zhou 2020-04-27 15:56:25 +08:00 committed by osborn
parent 0535d0d4d4
commit ab28256916

View File

@ -252,18 +252,18 @@ public class ImageNode extends ViewNode<ImageView> {
protected void setResource(@Nullable Drawable resource) {
if (resource instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable) resource).getBitmap();
float scale = DoricUtils.getScreenScale() / imageScale;
if (imageScale != DoricUtils.getScreenScale()) {
float scale = DoricUtils.getScreenScale() / imageScale;
Matrix matrix = new Matrix();
matrix.setScale(scale, scale);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
resource = new BitmapDrawable(getContext().getResources(), bitmap);
}
if (stretchInset != null) {
float left = stretchInset.getProperty("left").asNumber().toFloat();
float top = stretchInset.getProperty("top").asNumber().toFloat();
float right = stretchInset.getProperty("right").asNumber().toFloat();
float bottom = stretchInset.getProperty("bottom").asNumber().toFloat();
float left = stretchInset.getProperty("left").asNumber().toFloat() * scale;
float top = stretchInset.getProperty("top").asNumber().toFloat() * scale;
float right = stretchInset.getProperty("right").asNumber().toFloat() * scale;
float bottom = stretchInset.getProperty("bottom").asNumber().toFloat() * scale;
Rect rect = new Rect(
(int) left,