Android第三方开源图片裁剪截取:cropper
Android第三方开源图片裁剪截取:cropper
很多app都需要裁剪截取图片作为头像、logo之类,而cropper是github上的一个针对Android平台的、第三方开源图片裁剪截取项目,其项目主页是:https://github.com/edmodo/cropper
cropper项目给出的一个例子以一张蝴蝶图作为目标图片进行裁剪截取,如图:
cropper用法简单,给出一个例子,测试的MainActivity.java:
package zhangphil.demo; import com.edmodo.cropper.CropImageView; import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); final CropImageView cropImageView = (CropImageView) findViewById(R.id.CropImageView); // 当触摸时候才显示网格线
cropImageView.setGuidelines(CropImageView.GUIDELINES_ON_TOUCH); findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View v) {
// 获取裁剪成的图片
Bitmap croppedImage = cropImageView.getCroppedImage(); cropImageView.setImageBitmap(croppedImage);
}
});
}
}
需要的布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="zhangphil.demo.MainActivity" > <com.edmodo.cropper.CropImageView
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/CropImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/girl" /> <Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="裁剪" >
</Button> </LinearLayout>
附录文章:
1,《Android设置头像,手机拍照或从本地相册选取图片作为头像》链接地址:http://blog.csdn.net/zhangphil/article/details/44829747
Android第三方开源图片裁剪截取:cropper的更多相关文章
- Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog)
Android第三方开源对话消息提示框:SweetAlertDialog(sweet-alert-dialog) Android第三方开源对话消息提示框:SweetAlertDialog(sweet- ...
- Android第三方开源SeekBarCompat:音乐类播放器等APP进度条常用
Android第三方开源SeekBarCompat:音乐类播放器等APP进度条常用 Android平台原生的SeekBar设计简单,然而,比如现在流行的一些音乐播放器的播放进度控制条,如果直接使 ...
- Android第三方开源SwitchButton
Android第三方开源SwitchButton Android SwitchButton是github上的一个第三方开源项目,其项目主页是:https://github.com/kyleduo/Sw ...
- Android第三方开源下拉框:NiceSpinner
Android第三方开源下拉框:NiceSpinner Android原生的下拉框Spinner基本上可以满足Android开发对于下拉选项的设计需求,但现在越来越流行的下拉框不满足于Andro ...
- 030 Android 第三方开源下拉框:NiceSpinner的使用+自定义Button样式+shape绘制控件背景图+图片选择器(selector)
1.NiceSpinner下拉框控件介绍 Android原生的下拉框Spinner基本上可以满足Android开发对于下拉选项的设计需求,但现在越来越流行的下拉框不满足于Android原生提供的下拉框 ...
- Android 第三方开源库收集整理(转)
原文地址:http://blog.csdn.net/caoyouxing/article/details/42418591 Android开源库 自己一直很喜欢Android开发,就如博客签名一样, ...
- 45.Android 第三方开源库收集整理(转)
原文地址:http://blog.csdn.net/caoyouxing/article/details/42418591 Android开源库 自己一直很喜欢Android开发,就如博客签名一样, ...
- Android 第三方开源下拉框:NiceSpinner
Android原生的下拉框Spinner基本上可以满足Android开发对于下拉选项的设计需求,但现在越来越流行的下拉框不满足于Android原生提供的下拉框Spinner所提供的设计样式,而改用自定 ...
- 【我的Android进阶之旅】如何快速寻找Android第三方开源库在Jcenter上的最新版本
问题描述 解决方法 先了解compile comsquareupokhttpokhttp240的意义 了解Jcenter和Maven jcenter Maven Central 理解jcenter和M ...
随机推荐
- web跨域问题回顾
晚上看spring web源码时看到了cors包,查了一下原来是在4.2之后新加的用来更方便让web应用服务支持cors协议的.于是有了下面几个问题. web跨域问题的起源是因为浏览器为了安全而遵循的 ...
- PCB 钻孔补偿那点事
没有优秀的个人,只有优秀的团队,在团队共同的协作下,PCB CAM自动化[net处理]与[钻孔处理] 第一阶段开发项完成了,,后续工作可以转向PCB规则引擎开发了.这里说说PCB工程钻孔补偿的那点事, ...
- codevs3304水果姐逛街(线段数)
3304 水果姐逛水果街Ⅰ 时间限制: 2 s 空间限制: 256000 KB 题目等级 : 钻石 Diamond 题目描述 Description 水果姐今天心情不错,来到了水果街. 水果 ...
- Python基础数据类型(五) dict字典
字典dict{} 字典数字自动排序 enumerate 枚举 for i,k in enumerate(dic,1) #第二个参数默认不写就是0 ---枚举 print(i,k) dict,以{}来表 ...
- js 中的定时器
在js中的定时器分两种:1.setTimeout() 2.setInterval() 1.setTimeOut() 只在指定时间后执行一次 /定时器 异步运行 function hello(){ al ...
- MyBatis 配置控制台上显示sql语句(log4j.properties 之三)
### direct log messages to stdout ###log4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.app ...
- HTML中的行级标签和块级标签 《转换》
1.html中的块级标签 显示为“块”状,浏览器会在其前后显示折行.常用的块级元素包括: <p>, <ul>,<table>,<h1~h6>等. 2.h ...
- [ BZOJ 3445 ] Roadblock
\(\\\) \(Description\) 给出一张\(N\) 个点\(M\)条边的无向图,选择一条边使其权值翻倍,求操作后比操作前最短路长度增量最大值. \(1\le N\le 250\),\(1 ...
- 原生js实现简单的焦点图效果
用到一些封装好的运动函数,主要是定时器 效果为图片和图片的描述定时自动更换 <!DOCTYPE html> <html> <head> <meta chars ...
- PHP第二阶段学习 一、php的基本语法
php的基本语法 输出语句:a. echo输出:可以输出多个字符串,逗号隔开 b. print输出:只能输出一个字符串,返回true或false c. print_r():可以把字符串和数字简单 ...