【问题标题】:Android:Resize image to full width and height with Picasso just like instagramAndroid:使用 Picasso 将图像大小调整为全宽和全高,就像 instagram 一样
【发布时间】:2017-07-14 20:40:08
【问题描述】:

RecyclerView 中,图像显示为全高和全宽,并且没有拉伸,这可能吗?

【问题讨论】:

    标签: android image bitmap imageview


    【解决方案1】:

    使用android:scaleType="centerInside"

    ImageView.ScaleType CENTER_INSIDE 均匀缩放图像(保持图像的纵横比),使图像的两个尺寸(宽度和高度)都等于或小于视图的相应尺寸(减去填充)。

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="fixed_width_for_each_cell"
        android:layout_height="fixed_height_for_each_cell"
        android:scaleType="centerInside"
       />
    

    Center Inside 属性不会改变 Image Aspect Ratio 。如果您根据位图Aspect RatioImageView 提供高度和宽度,则其调整图像大小,因此应该显示其确定的完整图像。

    【讨论】:

      【解决方案2】:

      仅使用 android:scaleType="fitXY"

      【讨论】:

        【解决方案3】:

        试试这个代码

        Picasso.with(myContext).load(uri).resize(720, 720)
                            .centerCrop().into(aImageView);
        

        我认为它对你的情况有用。

        【讨论】:

          【解决方案4】:
            <ImageView
              android:id="@+id/imageView"
              android:layout_width="fixed_width_for_each_cell"
              android:layout_height="fixed_height_for_each_cell"
              android:scaleType="fitXY"
              android:adjustViewBounds="true"/>
          

          【讨论】:

            【解决方案5】:

            将此添加到您的 ImageView

            android:adjustViewBounds="true"
            android:scaleType="centerCrop"
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2014-03-20
              • 2014-01-16
              • 2012-01-13
              • 1970-01-01
              • 1970-01-01
              • 2014-03-23
              • 2015-02-10
              相关资源
              最近更新 更多