Android使用PhotoView實(shí)現(xiàn)圖片雙擊放大單擊退出效果
本文實(shí)例為大家分享了PhotoView實(shí)現(xiàn)圖片雙擊放大單擊退出的具體代碼,供大家參考,具體內(nèi)容如下
實(shí)現(xiàn)思路
1.復(fù)制PhotoView 到libs下,然后進(jìn)行添加小奶瓶
2.布局xml文件,添加PhotoView控件,src加載一張圖片,就已經(jīng)實(shí)現(xiàn)了放大縮小
3.Photoview設(shè)置點(diǎn)擊事件,實(shí)現(xiàn)單擊退出Activity
導(dǎo)jar包
compile files('libs/uk-co-senab-photoview.jar')
進(jìn)行布局
<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中實(shí)現(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(); } }); } }
好了,這就可以實(shí)現(xiàn)圖片雙擊放大,單擊退出的一個(gè)效果了,比較簡(jiǎn)單,大家可以做一下!
相關(guān)文章
詳解Android WebView監(jiān)聽console錯(cuò)誤信息
這篇文章主要介紹了Android WebView監(jiān)聽console錯(cuò)誤信息,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12Android實(shí)現(xiàn)短信驗(yàn)證碼獲取自動(dòng)填寫功能(詳細(xì)版)
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)短信驗(yàn)證碼獲取自動(dòng)填寫功能,很實(shí)用的功能分享給大家,感興趣的小伙伴們可以參考一下2016-08-08android Launcher AppWidget添加步驟介紹
大家好,本篇文章主要講的是android Launcher AppWidget添加步驟介紹,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽2022-01-01Android實(shí)現(xiàn)關(guān)機(jī)后數(shù)據(jù)不會(huì)丟失問(wèn)題
這篇文章主要介紹了Android實(shí)現(xiàn)關(guān)機(jī)后數(shù)據(jù)不會(huì)丟失問(wèn)題,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-10-10修改Android簽名證書keystore的密碼、別名alias以及別名密碼
這篇文章主要介紹了修改Android簽名證書keystore的密碼、別名alias以及別名密碼的相關(guān)資料,需要的朋友可以參考下2015-12-12Android按鈕按下的時(shí)候改變顏色實(shí)現(xiàn)方法
這篇文章主要介紹了Android按鈕按下的時(shí)候改變顏色實(shí)現(xiàn)方法,有需要的朋友可以參考一下2014-01-01Android利用ContentProvider讀取短信內(nèi)容
這篇文章主要為大家詳細(xì)介紹了Android利用ContentProvider讀取短信內(nèi)容,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-11-11