Android 實(shí)現(xiàn)IOS選擇拍照相冊底部彈出的實(shí)例
Android 實(shí)現(xiàn)IOS選擇拍照相冊底部彈出的實(shí)例
效果圖

1. AndroidStudio使用
dependencies {
compile 'com.guoqi.widget:actionsheet:1.0'
}
2. 使用
//1.實(shí)現(xiàn)接口
implements ActionSheet.OnActionSheetSelected
//2.在某個(gè)點(diǎn)擊事件中添加:
ActionSheet.showSheet(this, this, null);
//3.然后重寫點(diǎn)擊方法:
@Override
public void onClick(int whichButton) {
switch (whichButton) {
case ActionSheet.CHOOSE_PICTURE:
//相冊
choosePic();
break;
case ActionSheet.TAKE_PICTURE:
//拍照
takePic();
break;
case ActionSheet.CANCEL:
//取消
break;
}
}
//加入自己的邏輯
public void takePic(){
String state = Environment.getExternalStorageState();
if (state.equals(Environment.MEDIA_MOUNTED)) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File outDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
if (!outDir.exists()) {
outDir.mkdirs();
}
File outFile = new File(outDir, System.currentTimeMillis() + ".jpg");
picPath = outFile.getAbsolutePath();
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile));
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, ActionSheet.TAKE_PICTURE);
} else {
Toast.makeText(this, "請確認(rèn)已經(jīng)插入SD卡", Toast.LENGTH_SHORT).show();
}
}
//加入自己的邏輯
public void choosePic(){
Intent openAlbumIntent = new Intent(Intent.ACTION_PICK);
openAlbumIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
startActivityForResult(openAlbumIntent, ActionSheet.CHOOSE_PICTURE);
}
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持,如有疑問請留言或者到本站社區(qū)交流討論,大家共同進(jìn)步!
- Android仿Boss直聘文本日期混合滾輪選擇器示例
- Android 實(shí)現(xiàn)IOS 滾輪選擇控件的實(shí)例(源碼下載)
- Android滾輪選擇時(shí)間控件使用詳解
- Android高仿IOS 滾輪選擇控件
- 輕松實(shí)現(xiàn)可擴(kuò)展自定義的Android滾輪時(shí)間選擇控件
- Android實(shí)現(xiàn)底部圖片選擇Dialog
- Android 仿京東商城底部布局的選擇效果(Selector 選擇器的實(shí)現(xiàn))
- Android開發(fā)中實(shí)現(xiàn)IOS風(fēng)格底部選擇器(支持時(shí)間 日期 自定義)
- Android實(shí)現(xiàn)底部滾輪式選擇彈跳框
相關(guān)文章
Android基于IJKPlayer視頻播放器簡單封裝設(shè)計(jì)
這篇文章主要介紹了Android基于IJKPlayer視頻播放器簡單封裝設(shè)計(jì),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-06-06
android 設(shè)置圓角圖片實(shí)現(xiàn)代碼
在android應(yīng)用開發(fā)中,可能是美化需要,圖片需要處理成圓角,本文將給出實(shí)現(xiàn)代碼,開發(fā)中的遇到此問題的朋友可以參考下2012-11-11
Android開發(fā)之Sqliteopenhelper用法實(shí)例分析
這篇文章主要介紹了Android開發(fā)之Sqliteopenhelper用法,實(shí)例分析了SQLiteOpenHelper類操作數(shù)據(jù)庫的相關(guān)技巧,需要的朋友可以參考下2015-05-05
android studio安裝時(shí) AVD出現(xiàn)問題如何快速解決
這篇文章主要介紹了安裝android studio時(shí) AVD出現(xiàn)問題如何快速處理,其實(shí)解決方法也很簡單,文中通過截圖的形式給大家及時(shí)的非常詳細(xì),對大家的工作或?qū)W習(xí)具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-03
Android.permission.MODIFY_PHONE_STATE權(quán)限問題解決辦法
這篇文章主要介紹了Android.permission.MODIFY_PHONE_STATE權(quán)限問題解決辦法的相關(guān)資料,這里提供了幾種方法幫助大家解決這種問題,需要的朋友可以參考下2016-12-12
Android性能優(yōu)化死鎖監(jiān)控知識點(diǎn)詳解
這篇文章主要為大家介紹了Android性能優(yōu)化死鎖監(jiān)控知識點(diǎn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-10-10

