开发者

scale an image to fit TOP and RIGHT in android ImageView

I use an ImageView, I wa开发者_Python百科nt the source image to fit to the TOP and RIGHT.

FitEnd scaling fits BOTTOM and RIGHT all other scale enums don't help much as well

any idea?

Thanks


Try this code

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

This should get you the intended result.


I beleive you are looking for the fitStart or, in code, setScaleType(ImageView.ScaleType.FIT_START);

Using that you could simply wrap the image in a layout wrapper that is aligned to the right, such as a RelativeLayout with android:layout_alignParentRight="true"


Just use scaleType = MATRIX

e.g:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜