How to fit image in full screen in ImageViewTouch

2019-07-18 06:08发布

I am using [ImageViewTouch][1] library to zoom a image instead of imageview.

<it.sephiroth.android.library.imagezoom.ImageViewTouch
           android:id="@+id/imageweb"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
            android:adjustViewBounds="true"
           android:background="@drawable/bg_loading"
           android:scaleType="fitCenter" />

I want to load the image on ImageViewTouch control and the width of image will auto fits my screen. How to fit only width and height both to my mobile screen?

Here when i do 3 times double tap means in 1st time its get zoomed in 2nd time also but in 3rd times its fits to height and width of the the device screen perfectly why its not fit at the time of first time.

But its not loaded fit to height and width at first time.? Please help me to sort out this issue.

I used this library classes May be i have to change here some thing.

1) [first][2]
2) [second][3] 

Please Check Screenshots :

When first time its loaded automatically : enter image description here

After 3 times double tap means here first and second time zoom and 3rd time its fits perfectly why its not fitted at the time of first time when imageview loaded this image.

enter image description here

I already tried below answers but its not works.

Thank you for support

6条回答
别忘想泡老子
2楼-- · 2019-07-18 06:20

Try to call function setDisplayType(DisplayType.FIT_TO_SCREEN) for your imageView

查看更多
看我几分像从前
3楼-- · 2019-07-18 06:24

I had the same issue. After trying a few workarounds without success, finally solved it switching to this library: https://github.com/MikeOrtiz/TouchImageView

查看更多
别忘想泡老子
4楼-- · 2019-07-18 06:39

Taken from the example app:

<it.sephiroth.android.library.imagezoom.ImageViewTouch
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:scaleType="fitCenter" />
查看更多
ゆ 、 Hurt°
5楼-- · 2019-07-18 06:42

In it.sephirot.android.library.imagezoom.ImageViewTouchBase change the line

protected DisplayType mScaleType = DisplayType.FIT_IF_BIGGER;

in

protected DisplayType mScaleType = DisplayType.FIT_TO_SCREEN;
查看更多
Evening l夕情丶
6楼-- · 2019-07-18 06:43
<it.sephiroth.android.library.imagezoom.ImageViewTouch
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scaleType="fitXY" />

I think fitXY is fit with the xy coordinate

查看更多
The star\"
7楼-- · 2019-07-18 06:43

Scale type in the xml will not work. You should use the library. Scale type is set in this class, change the scale type Here go to it.sephiroth.android.library.imagezoom.ImageViewTouch

in this class you can see setScaleType(ScaleType.MATRIX); change this to setScaleType(ScaleType.FIT_XY);

查看更多
登录 后发表回答