【问题标题】:scale an image to fit TOP and RIGHT in android ImageView缩放图像以适合 android ImageView 中的 TOP 和 RIGHT
【发布时间】:2011-10-11 17:09:51
【问题描述】:

我使用ImageView,我希望源图片适合TOPRIGHT

FitEnd 缩放适合 BOTTOMRIGHT 所有其他比例 enums 也无济于事

有什么想法吗?

谢谢

【问题讨论】:

    标签: android imageview image-scaling


    【解决方案1】:

    试试这个代码

    <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:gravity="top|right">
       <ImageView
           android:scaleType="fitEnd"
           android:adjustViewBounds="true" />
    </LinearLayout>
    

    这应该会得到预期的结果。

    【讨论】:

    • 这是一个糟糕的答案,因为代码杂乱无章(双引号的使用不一致),而且简短的解释性段落提供的启示很少。
    • @CarlosP 我猜你忘了读它是一个伪代码。我不相信勺子喂养的答案,并期望对方付出一些努力。
    【解决方案2】:

    我相信您正在寻找 fitStart 或代码中的 setScaleType(ImageView.ScaleType.FIT_START);

    使用它,您可以简单地将图像包装在向右对齐的布局包装器中,例如带有android:layout_alignParentRight="true"的RelativeLayout

    【讨论】:

      【解决方案3】:

      只需使用 scaleType = MATRIX

      例如:

      <ImageView
          android:layout_width="%wanted width%"
          android:layout_height="%wanted height%"
          android:scaleType="matrix"
          android:src="%your src%" />
      

      【讨论】:

        猜你喜欢
        • 2014-07-02
        • 2021-04-07
        • 2011-09-03
        • 1970-01-01
        • 2021-11-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-31
        相关资源
        最近更新 更多