Android之PhtoView设置图片放大缩小后,图片显示在界面上左上角的解决办法

          Android之PhtoView设置图片放大缩小后,当调用mAttacher = new PhotoViewAttacher(imageView) 。图片显示在界面上左上角。在网上找了好久也没找到解决办法,看来只能靠自己了。

          找到源代码,发现里面有个PhotoView类,再一看这个是继承自ImageView。那么为什么要继承自ImageView呢。难道这是个自定义控件。好吧,我带布局文件中直接使用了自定义的这个控件。

         具体布局文件如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/zhidao_details_tv_bg" >
   
   <uk.co.senab.photoview.PhotoView <!--注意这里的用的不是ImageView-->
    android:id="@+id/img_schedule"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:layout_centerInParent="true"/>

</RelativeLayout>

        然后在代码里,

private PhotoView imageView;

......


imageView = (PhotoView) this.findViewById(R.id.img_schedule);

......

ImageLoader.getInstance().displayImage(imageUrl,imageView);

mAttacher = new PhotoViewAttacher(imageView);//这句写上之后就可以多点触摸方法缩小啦。


     发表一下感慨,遇到问题时不要轻言放弃。静下心来,仔细分析分析。说不定哪个瞬间就找到解决问题的方法了。

    这个问题找了好久貌似都没有找到答案。这里分享给大家,希望对大家有帮助。如果觉得有用,不妨赞一下哦~ O(∩_∩)O哈哈~

    附PhotoView的library下载地址: http://pan.baidu.com/s/1rJIaL

    如果有任何疑问,欢迎Email to me :junkedeng@163.com

    





转载于:https://my.oschina.net/u/919173/blog/184762

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值