原创
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
//底部弹出的对话框 public voidbottomPopUp() {finalDialog dialog =newDialog(activity,R.style.style_dialog_bottom_pop_up); dialog.setCanceledOnTouchOutside(false); Window window = dialog.getWindow(); window.setGravity(Gravity.BOTTOM);//window.setGravity(Gravity.BOTTOM); window.getDecorView().setPadding(0,0,0,0);//消除边距 WindowManager.LayoutParams lp = window.getAttributes(); lp.gravity= Gravity.BOTTOM; //设置背景层透明度 lp.dimAmount=0.3f; lp.width= WindowManager.LayoutParams.MATCH_PARENT;//设置宽度充满屏幕 lp.height= WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(lp); dialog.show(); View contentView = LayoutInflater.from(activity).inflate(R.layout.dialog_bottom_pop_up, null); //拍照 TextView mTakePhoto = (TextView) contentView.findViewById(R.id.takePhoto); mTakePhoto.setOnClickListener(newView.OnClickListener() {//拍照 @Override public voidonClick(View v) { intentCamera(); dialog.dismiss(); } }); //选择相册 selectorPhoto(dialog,contentView); //取消 TextView mChoose_photo_cancle = (TextView) contentView.findViewById(R.id.choose_photo_cancle); mChoose_photo_cancle.setOnClickListener(newView.OnClickListener() {//取消 @Override public voidonClick(View v) {dialog.dismiss(); } }); window.setContentView(contentView); } private voidselectorPhoto(finalDialog dialog,View contentView) { TextView mChoosePhoto = (TextView) contentView.findViewById(R.id.choosePhoto); mChoosePhoto.setOnClickListener(newView.OnClickListener() {//从相册 @Override public voidonClick(View v) { PhotoPickerIntent intent =newPhotoPickerIntent(activity); intent.setPhotoCount(5); intent.setShowCamera(true); MyApp.stackInstance().getCurrentActivity().startActivityForResult(intent,REQUEST_CODE_UPLOAD_IMAGE); dialog.dismiss(); } }); } private voidintentCamera() { Intent cameraIntent =newIntent(MediaStore.ACTION_IMAGE_CAPTURE); //设置图片文件路径, mPhotoPath= getSDPath() +"/"+ getPhotoFileName(); mPhotoFile=newFile(mPhotoPath); if(!mPhotoFile.exists()) {try{mPhotoFile.createNewFile();//创建新文件 }catch(IOException e) { e.printStackTrace(); } }if(Build.VERSION.SDK_INT>=24) {imageUri= FileProvider.getUriForFile(activity,"com.jkgj.skymonkey.doctor.ui.view.fleprovider",mPhotoFile); }else{imageUri= Uri.fromFile(mPhotoFile); } cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT,//Intent有了图片的信息 imageUri); cameraIntent.putExtra(GlobalField.CAMERA_PATH,mPhotoPath); //通知图库更新 MyApp.stackInstance().getCurrentActivity().sendBroadcast(newIntent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,imageUri)); MyApp.stackInstance().getCurrentActivity().startActivityForResult(cameraIntent,CAMERA_REQUEST); } publicStringgetSDPath() { File sdDir =null; booleansdCardExist = Environment.getExternalStorageState() .equals(android.os.Environment.MEDIA_MOUNTED);//判断sd卡是否存在 if(sdCardExist) { sdDir = Environment.getExternalStorageDirectory();//获取跟目录 }returnsdDir.toString(); } privateStringgetPhotoFileName() { Date date =newDate(System.currentTimeMillis()); SimpleDateFormat dateFormat =newSimpleDateFormat("'IMG'_yyyyMMdd_HHmmss"); returndateFormat.format(date) +"jk.jpg"; }
有0 个人打赏
[Android]仿IOS选择拍照相册底部弹出框@AuthorGQ2016年07月18日由于主要用来弹出选择拍照和选择相册功能,就限定只有两个条目。没有像网上其他demo一样做扩展。可以配合网上的Im...博文来自: 代码一挖一麻袋
有时候,前端开发需要点击图片实现弹出相册效果(图片查看器),可以放大预览图片并且左右翻页切换,layer.js可以很轻松实现(layer.photos(options))。实现步骤1、导入相关laye...博文来自: l960516的博客
@OnClick(R.id.simpleDraweeView)publicvoidonViewClicked(){AlertDialog.Builderbuilder=newAlertDialog.B...博文来自: qq_40694956的博客
//联系人:石虎QQ:1224614774昵称:嗡嘛呢叭咪哄/**注意点:1.看GIF效果图.2.看连线视图的效果图.3.看实现代码(直接复制实现效果).4.此dome必须使...博文来自: 石虎
在项目开发过程中,需要在个人中心模块点击用户头像使底部弹出弹窗,显示相机获取、相册获取等选项,这里本来想使用AndroidMaterialDesign风格的界面,然而UI小姐姐不管三七二十一,要求界面...博文来自: u014078990的博客