com.github.chrisbanes.Photo查看并按高度缩放图像

时间:2017-07-11 03:49:14

标签: android image

我正在尝试使用PhotoView,我希望该图像能够像在Android的壁纸应用中一样显示。

所以看起来壁纸应用中的图像按比例缩小或向上缩小以填充屏幕,但宽度似乎没有变化,因此如果要查看整个图片,则必须进行缩放或向左和/或向右滚动?这是否使用了setDisplayMatrix方法?如果是这样,那个方法调用怎么样?这是我的xml示例,但我正在使用Glide来设置图像,如果我需要放弃Glide并直接使用PhotoView小部件我也会这样做,如果这会产生所需的效果。

<com.github.chrisbanes.photoview.PhotoView xmlns:android="http://schemas.android.com/apk/res/android"
                                       xmlns:tools="http://schemas.android.com/tools"
                                       android:id="@+id/photoView"
                                       android:layout_width="match_parent"
                                       android:layout_height="match_parent"
                                       tools:showIn="@layout/activity_wallpaper_viewer"/>

1 个答案:

答案 0 :(得分:0)

将图像投入Horizo​​ntalScrollView,将xml稍微更改为此

<com.github.chrisbanes.photoview.PhotoView
    android:id="@+id/photoView" android:adjustViewBounds="true"
    android:layout_width="wrap_content" android:layout_height="match_parent"/>

简单......令人尴尬......