【问题标题】:Center crop image with background居中裁剪图像与背景
【发布时间】:2021-07-05 19:53:42
【问题描述】:

正如我需要做的图片,我努力去做但我仍然没有得到结果。

结果:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_gravity="center_vertical"
        android:scaleType="centerCrop"/>
</RelativeLayout>

【问题讨论】:

    标签: android layout imageview


    【解决方案1】:
       android:scaleType="fitCenter"  // try this
    

    【讨论】:

      【解决方案2】:

      这种结果不需要scaleType,添加背景色就足够了。

      <RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent">
      
          <ImageView
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#000000"
              android:src="@drawable/hello"
              />
      </RelativeLayout>
      

      【讨论】:

        猜你喜欢
        • 2015-10-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-10
        相关资源
        最近更新 更多