xuanzhiqiang 2019-12-11
<ImageView android:id="@+id/qrcodeImg" android:layout_width="300dp" android:layout_height="300dp" android:scaleType="fitCenter" android:background="@color/blue" />
Glide.with(getContext()).load(AppModel.GetInstance().getUserQrcodePath()).into(qrcodeImg); int screenWidth = QMUIDisplayHelper.getScreenWidth(getContext()); int screenHeight = QMUIDisplayHelper.getScreenHeight(getContext()); ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) qrcodeImg.getLayoutParams(); int maxWidth = (int) (screenWidth * 0.7); int maxHeight = (int) (screenHeight * 0.6); layoutParams.width = maxWidth; layoutParams.height = maxHeight; qrcodeImg.setAdjustViewBounds(true); qrcodeImg.setMaxWidth(maxWidth); qrcodeImg.setMaxHeight(maxHeight);