Android使用PhotoView實現(xiàn)圖片雙擊放大單擊退出效果
本文實例為大家分享了PhotoView實現(xiàn)圖片雙擊放大單擊退出的具體代碼,供大家參考,具體內(nèi)容如下
實現(xiàn)思路
1.復(fù)制PhotoView 到libs下,然后進行添加小奶瓶
2.布局xml文件,添加PhotoView控件,src加載一張圖片,就已經(jīng)實現(xiàn)了放大縮小
3.Photoview設(shè)置點擊事件,實現(xiàn)單擊退出Activity
導(dǎo)jar包
compile files('libs/uk-co-senab-photoview.jar')
進行布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent"> <uk.co.senab.photoview.PhotoView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/pv" android:src="@drawable/ic_emptya"/> </RelativeLayout>
在MainActivity中實現(xiàn)
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); PhotoView pv = (PhotoView) findViewById(R.id.pv); pv.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float v, float v1) { finish(); } }); } }
好了,這就可以實現(xiàn)圖片雙擊放大,單擊退出的一個效果了,比較簡單,大家可以做一下!
相關(guān)文章
詳解Android WebView監(jiān)聽console錯誤信息
這篇文章主要介紹了Android WebView監(jiān)聽console錯誤信息,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-12-12Android實現(xiàn)短信驗證碼獲取自動填寫功能(詳細(xì)版)
這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)短信驗證碼獲取自動填寫功能,很實用的功能分享給大家,感興趣的小伙伴們可以參考一下2016-08-08android Launcher AppWidget添加步驟介紹
大家好,本篇文章主要講的是android Launcher AppWidget添加步驟介紹,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽2022-01-01Android實現(xiàn)關(guān)機后數(shù)據(jù)不會丟失問題
這篇文章主要介紹了Android實現(xiàn)關(guān)機后數(shù)據(jù)不會丟失問題,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2019-10-10修改Android簽名證書keystore的密碼、別名alias以及別名密碼
這篇文章主要介紹了修改Android簽名證書keystore的密碼、別名alias以及別名密碼的相關(guān)資料,需要的朋友可以參考下2015-12-12Android利用ContentProvider讀取短信內(nèi)容
這篇文章主要為大家詳細(xì)介紹了Android利用ContentProvider讀取短信內(nèi)容,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-11-11