新建一个modul
里面加入这几个类(前提必须把这个modul变成可依赖的Library)
首先去build.gradle首行改为
apply plugin: 'com.android.library'
删除defaultConfig里面的appliaction要不然会报错
错误:Library....
地址:http://git.oschina.net/TianBinRui/phopoview/tree/master
Compat
CustomGestureDetector
OnGestureListener
OnMatrixChangedListener
OnOutsidePhotoTapListener
OnPhotoTapListener
OnScaleChangedListener
OnSingleFlingListener
OnViewDragListener
OnViewTapListener
PhotoView
PhotoViewAttacher
Util
用另一个modul依赖第一个modul加入依赖
首先添加联网权限
<uses-permission android:name="android.permission.INTERNET" />
在xml中添加属性(financialshare.com.ptpview.PhotoView路劲)
<financialshare.com.ptpview.PhotoView android:id="@+id/iv_photo" android:layout_width="match_parent" android:layout_height="match_parent"/>
在Activity中添加以下代码
PhotoView photoView = (PhotoView) findViewById(R.id.iv_photo); Picasso.with(this) .load("http://img.1985t.com/uploads/attaches/2017/06/122920-Qr51Tnt.jpg") .into(photoView); photoView.setOnPhotoTapListener(new OnPhotoTapListener() { @Override public void onPhotoTap(ImageView view, float x, float y) { //fullScreen(); } }); fullScreen();
public void fullScreen() { // BEGIN_INCLUDE (get_current_ui_flags) // The UI options currently enabled are represented by a bitfield. // getSystemUiVisibility() gives us that bitfield. int uiOptions = getWindow().getDecorView().getSystemUiVisibility(); int newUiOptions = uiOptions; // END_INCLUDE (get_current_ui_flags) // BEGIN_INCLUDE (toggle_ui_flags) boolean isImmersiveModeEnabled = isImmersiveModeEnabled(); if (isImmersiveModeEnabled) { Log.i("TEST", "Turning immersive mode mode off. "); } else { Log.i("TEST", "Turning immersive mode mode on."); } // Navigation bar hiding: Backwards compatible to ICS. if (Build.VERSION.SDK_INT >= 14) { newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } // Status bar hiding: Backwards compatible to Jellybean if (Build.VERSION.SDK_INT >= 16) { newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN; } // Immersive mode: Backward compatible to KitKat. // Note that this flag doesn't do anything by itself, it only augments the behavior // of HIDE_NAVIGATION and FLAG_FULLSCREEN. For the purposes of this sample // all three flags are being toggled together. // Note that there are two immersive mode UI flags, one of which is referred to as "sticky". // Sticky immersive mode differs in that it makes the navigation and status bars // semi-transparent, and the UI flag does not get cleared when the user interacts with // the screen. if (Build.VERSION.SDK_INT >= 18) { newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } getWindow().getDecorView().setSystemUiVisibility(newUiOptions); //END_INCLUDE (set_ui_flags) } private boolean isImmersiveModeEnabled() { return ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions); }