AdjustViewBoundsプロパティの使用



Adjustviewbounds Property Use



問題が発生する

  • 問題の説明

いつScrollView大きすぎる画像を含めると、大きな空白が自動的に上に追加されます

  • レイアウトファイル
ImageView
  • 異常なレンダリング



    画像

問題が解決しました

android:adjustViewBounds='true'属性を追加ImageView



  • 変更されたレイアウト
Set this to true if you want the ImageView to adjust its bounds to preserve the aspect ratio of its drawable.

公式文書

google公式APIアドレス https://developer.android.com/reference/android/widget/ImageView.html

  • setAdjustViewBounds

画像

  • android:adjustViewBounds

画像



上記の2つのブロックで1つの文しか話されていないことがわかります

If you want the ImageView to adjust the borders to retain its drawable aspect ratio, set it to true.

setMaxWidth翻訳の結果は

adjustViewBounds

  • setMaxWidth

setMaxWidth

有効 翻訳は 効果的

上の赤​​いボックスの意味はThe android:adjustViewBounds property of ImageView is whether to maintain the aspect ratio of the original image. Setting it separately does not work. It needs to be used together with maxWidth or maxHeight. ですこのプロパティはmaxWidthにのみ存在します属性がtrueの場合に有効です。

  • インターネット上に広がる
adjustViewBounds

この文は依存関係を逆転させるはずです。adjustViewBoundsプロパティは依存します

および

個別に設定でき、効果的です。