时间:2021-05-20
android 从图库中选取图片
在android中,如何从图库gallary中挑选图片呢,其实很简单,步骤如下
1) 设计一个imageview,用来显示图库选出来的图片
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:id="@+id/imgView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content"></ImageView> <Button android:layout_height="wrap_content" android:text="Load Picture" android:layout_width="wrap_content" android:id="@+id/buttonLoadPicture" android:layout_weight="0" android:layout_gravity="center"></Button> </LinearLayout>2) 学习如何在按键中调出gallary,其实也就是intent了,如下
3) 然后在onActivityResult中对调出图库后,选定好的图片,我们要重新显示在页面的imageview中,因此代码如下:
其中就是Uri selectedImage = data.getData();获得了图库中的图片所有数据了。
这样一来,当用户在图库中选好图片后,就可以呈现在imageview控件中咯
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了android从系统图库中取图片的实现方法。分享给大家供大家参考。具体如下:在自己应用中,从系统图库中取图片,然后截取其中一部分,再返回到自己应用
IOSUIImagePickerController从拍照、图库、相册获取图片iOS获取图片有三种方法:1.直接调用摄像头拍照2.从相册中选择3.从图库中选择U
UIImagePickerController从拍照、图库、相册获取图片iOS获取图片有三种方法:1.直接调用摄像头拍照2.从相册中选择3.从图库中选择UIIm
android相机拍照直接选取图片固然方便,但是更多的时候,我们需要从手机已有的图片中选择一张来使用。这次就练习如何从相册中选择图片吧。首先在activity_
本文实例讲述了Android编程实现调用系统图库与裁剪图片功能。分享给大家供大家参考,具体如下:在Android开发中,调用系统图库和裁剪照片是很常见的需求。相