From 447a786632860ed59b42d266397bc48b53dce1a8 Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Wed, 10 Dec 2025 20:31:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=B0=BA=E5=AF=B8=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=87=BD=E6=95=B0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- powerbell/build.properties | 4 +- .../powerbell/views/BackgroundView.java | 59 ++++++++++--------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/powerbell/build.properties b/powerbell/build.properties index 88f7924..c427d23 100644 --- a/powerbell/build.properties +++ b/powerbell/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Wed Dec 10 20:11:13 HKT 2025 +#Wed Dec 10 12:27:54 GMT 2025 stageCount=12 libraryProject= baseVersion=15.12 publishVersion=15.12.11 -buildCount=0 +buildCount=1 baseBetaVersion=15.12.12 diff --git a/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java b/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java index dc5c003..4826514 100644 --- a/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java +++ b/powerbell/src/main/java/cc/winboll/studio/powerbell/views/BackgroundView.java @@ -132,7 +132,7 @@ public class BackgroundView extends RelativeLayout { setDefaultTransparentBackground(); return; } - + mIvBackground.setVisibility(View.GONE); // 计算原图比例 @@ -211,37 +211,38 @@ public class BackgroundView extends RelativeLayout { // 获取LinearLayout尺寸 int llWidth = mLlContainer.getWidth(); int llHeight = mLlContainer.getHeight(); - if (llWidth == 0 || llHeight == 0) { - postDelayed(new Runnable() { - @Override - public void run() { - adjustImageViewSize(); - } - }, 100); - return; - } +// if (llWidth == 0 || llHeight == 0) { +// postDelayed(new Runnable() { +// @Override +// public void run() { +// adjustImageViewSize(); +// } +// }, 100); +// return; +// } - // 计算ImageView尺寸(保持比例,不超出LinearLayout) - int ivWidth, ivHeight; - if (mImageAspectRatio >= 1.0f) { - ivWidth = Math.min((int) (llHeight * mImageAspectRatio), llWidth); - ivHeight = (int) (ivWidth / mImageAspectRatio); - } else { - ivHeight = Math.min((int) (llWidth / mImageAspectRatio), llHeight); - ivWidth = (int) (ivHeight * mImageAspectRatio); - } + if (llWidth != 0 && llHeight != 0) { + // 计算ImageView尺寸(保持比例,不超出LinearLayout) + int ivWidth, ivHeight; + if (mImageAspectRatio >= 1.0f) { + ivWidth = Math.min((int) (llHeight * mImageAspectRatio), llWidth); + ivHeight = (int) (ivWidth / mImageAspectRatio); + } else { + ivHeight = Math.min((int) (llWidth / mImageAspectRatio), llHeight); + ivWidth = (int) (ivHeight * mImageAspectRatio); + } - // 应用尺寸 - LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mIvBackground.getLayoutParams(); - params.width = ivWidth; - params.height = ivHeight; - mIvBackground.setLayoutParams(params); - mIvBackground.setScaleType(ScaleType.FIT_CENTER); // 确保居中平铺 - mIvBackground.setVisibility(View.VISIBLE); - + // 应用尺寸 + LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mIvBackground.getLayoutParams(); + params.width = ivWidth; + params.height = ivHeight; + mIvBackground.setLayoutParams(params); + mIvBackground.setScaleType(ScaleType.FIT_CENTER); // 确保居中平铺 + mIvBackground.setVisibility(View.VISIBLE); - //LogUtils.d(TAG, "ImageView尺寸:" + ivWidth + "x" + ivHeight); - //LogUtils.d(TAG, "=== adjustImageViewSize 完成 ==="); + //LogUtils.d(TAG, "ImageView尺寸:" + ivWidth + "x" + ivHeight); + //LogUtils.d(TAG, "=== adjustImageViewSize 完成 ==="); + } } private void setDefaultTransparentBackground() {