RoundedImageView
================
A fast ImageView (and Drawable) that supports rounded corners (and ovals or circles) based on the original [example from Romain Guy](http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/)
![RoundedImageView screenshot](https://raw.github.com/makeramen/RoundedImageView/master/screenshot.png)
![RoundedImageView screenshot with ovals](https://raw.github.com/makeramen/RoundedImageView/master/screenshot-oval.png)
There are many ways to create rounded corners in android, but this is the fastest and best one that I know of because it:
* does **not** create a copy of the original bitmap
* does **not** use a clipPath which is not hardware accelerated and not anti-aliased.
* does **not** use setXfermode to clip the bitmap and draw twice to the canvas.
If you know of a better method, let me know and I'll implement it!
Also has proper support for:
* Borders (with Colors and ColorStateLists)
* Ovals and Circles
* All `ScaleType`s
* Borders are drawn at view edge, not bitmap edge.
* Except on edges where the bitmap is smaller than the view
* Borders are **not** scaled up/down with the image (correct width and radius are maintained)
* Anti-aliasing
* Transparent backgrounds
* Hardware acceleration
* Support for LayerDrawables (including TransitionDrawables)
Gradle
----
RoundedImageView is available on Maven Central.
Add the following to your `build.gradle` to use:
```
repositories {
mavenCentral()
}
dependencies {
compile 'com.makeramen:roundedimageview:1.2.4'
}
```
Maven (Deprecated)
----
Make sure you installed Android 4.2 from the [Android Maven Deployer](https://github.com/mosabua/maven-android-sdk-deployer)
Build the apk:
```
git clone https://github.com/vinc3m1/RoundedImageView.git
cd ./RoundedImageView/
mvn clean install
```
Install and run:
````
cd ./example
mvn android:deploy android:run
````
If you want to use the library, add this dependency:
```
<dependency>
<groupId>com.makeramen</groupId>
<artifactId>roundedimageview-apklib</artifactId>
<version>1.2.0</version>
<type>apklib</type>
</dependency>
```
Usage
----
Define in xml:
```xml
<com.makeramen.RoundedImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imageView1"
android:src="@drawable/photo1"
android:scaleType="centerCrop"
app:corner_radius="30dip"
app:border_width="2dip"
app:border_color="#333333"
app:round_background="true"
app:is_oval="true" />
```
Or in code:
```java
RoundedImageView iv = new RoundedImageView(context);
iv.setScaleType(ScaleType.CENTER_CROP);
iv.setCornerRadius(10);
iv.setBorderWidth(2);
iv.setBorderColor(Color.DKGRAY);
iv.setRoundedBackground(true);
iv.setImageDrawable(drawable);
iv.setBackground(backgroundDrawable);
iv.isOval(true);
```
ChangeLog
----------
* **1.2.4**
* add basic support for ColorDrawable (and other drawables with -1 intrinsic dimens)
* implementation of the above is known to be buggy in many cases, pull requests welcome
* **1.2.3**
* added rudimentary support for `setImageUri`. Performance of the function is probably poor and users should be cautious when using it.
* **1.2.2**
* fix for incorrect radius on the image when there is a border
* add a `toBitmap()` function for easier Picasso and Ion compatibility
* **1.2.1**
* default scaleType now FIT_CENTER (and never null) to match Android ([#27](https://github.com/vinc3m1/RoundedImageView/issues/27))
* **1.2.0**
* add `setDither` and `setFilterBitmap` method support on RoundedDrawable for tuning bitmap scaling quality
* improved performance for `setImageResource`
* RoundedDrawable constructor is now public
* Fixed bug where artifact was downloading `aar.asc` file instead of aar. You no longer need to have `@aar` specified in the dependency
* **1.1.0**
* LayerDrawable support (needs testing!)
* Refactored api to support chaining and remove repetitive code
* **1.0.0**
* Initial release to maven central
* Programmatically setting attributes with TransitionDrawables not supported.
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/vinc3m1/roundedimageview/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
没有合适的资源?快使用搜索试试~ 我知道了~
创建抗锯齿透明背景圆角图像.zip
共49个文件
xml:15个
png:8个
jpg:7个
0 下载量 32 浏览量
2024-04-19
20:24:04
上传
评论
收藏 3.19MB ZIP 举报
温馨提示
android 源码学习. 资料部分来源于合法的互联网渠道收集和整理,供大家学习参考与交流。本人不对所涉及的版权问题或内容负法律责任。如有侵权,请通知本人删除。感谢CSDN官方提供大家交流的平台
资源推荐
资源详情
资源评论
收起资源包目录
创建抗锯齿透明背景圆角图像.zip (49个子文件)
创建抗锯齿透明背景圆角图像
screenshot.png 199KB
RoundedImageView-master
gradle
wrapper
gradle-wrapper.jar 49KB
gradle-wrapper.properties 230B
screenshot-oval.png 194KB
pom.xml 4KB
NOTICE.txt 12KB
gradlew.bat 2KB
build.gradle 330B
settings.gradle 47B
screenshot.png 199KB
gradlew 5KB
roundedimageview
pom.xml 3KB
src
com
makeramen
RoundedDrawable.java 11KB
RoundedImageView.java 8KB
res
values
attrs.xml 422B
build.gradle 2KB
proguard-project.txt 781B
AndroidManifest.xml 255B
.gitignore 354B
example
ic_launcher-web.png 74KB
pom.xml 1KB
src
com
makeramen
example
RoundedFragment.java 4KB
ExampleActivity.java 1KB
ColorFragment.java 3KB
PicassoFragment.java 4KB
lint.xml 52B
res
drawable-nodpi
photo6.jpg 423KB
photo4.jpg 432KB
photo2.jpg 325KB
photo3.jpg 300KB
photo7.jpg 146KB
photo5.jpg 512KB
photo1.jpg 293KB
drawable-mdpi
ic_launcher.png 5KB
drawable-xhdpi
ic_launcher.png 14KB
values-v14
styles.xml 362B
drawable-ldpi
ic_launcher.png 3KB
color
border.xml 246B
values-v11
styles.xml 307B
values
strings.xml 328B
styles.xml 637B
layout
fragment_rounded.xml 529B
rounded_item.xml 2KB
picasso_item.xml 2KB
drawable-hdpi
ic_launcher.png 9KB
build.gradle 581B
proguard-project.txt 781B
AndroidManifest.xml 841B
README.md 4KB
共 49 条
- 1
资源评论
Soft_Leader
- 粉丝: 855
- 资源: 1628
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于SHT25温湿度传感器、FREERTOS、STM32F103C8T6、LCD1602温湿度采集显示系统proteus仿真设计
- C# 屏幕放大取色器 随时随地获取屏幕像素颜色
- 下载安装这个软件.apk
- 【数据集详细解释及案例分析】数据集详细解释及案例分析
- 基于SHT71温湿度传感器、STM32F103C8T6、LCD1602温湿度采集显示系统proteus仿真设计
- 基于TH02温湿度传感器、STM32F103C8T6、LCD1602、FREERTOS的温湿度采集系统proteus仿真设计
- 【TCP-IP协议详细解释及案例分析】TCP-IP协议详细解释及案例分析
- 一文搞懂 LSTM(长短期记忆网络).rar
- 【autosar简介及基本案例解析】autosar简介及基本案例解析
- java模拟斗地主洗牌发牌
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功