您的位置:首页 > 移动开发 > Android开发

Android使用PhotoView实现图片缩放功能

2013-12-09 21:53 766 查看
使用第三方开源项目,地址:https://github.com/chrisbanes/PhotoView



引入library 项目.



简单的加载一张图片:

[java]
view plaincopy

public class MainActivity extends Activity {

ImageView imgView;
PhotoViewAttacher attacher;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imgView=(ImageView) findViewById(R.id.img);
imgView.setImageResource(R.drawable.wallpaper);
attacher=new PhotoViewAttacher(imgView);
}
}

布局文件:

[html]
view plaincopy

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img" />

</RelativeLayout>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐