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")
没有合适的资源?快使用搜索试试~ 我知道了~
Android应用源码之Android创建抗锯齿透明背景圆角图像.zip
共49个文件
xml:15个
png:8个
jpg:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 43 浏览量
2022-11-01
20:49:32
上传
评论
收藏 3.13MB ZIP 举报
温馨提示
Android应用设计源码安卓实例源代码,仅供学习及设计参考。
资源推荐
资源详情
资源评论
收起资源包目录
Android应用源码之Android创建抗锯齿透明背景圆角图像.zip (49个子文件)
Android应用源码之Android创建抗锯齿透明背景圆角图像
RoundedImageView-master
gradlew.bat 2KB
gradlew 5KB
example
pom.xml 1KB
res
drawable-ldpi
ic_launcher.png 3KB
values-v11
styles.xml 307B
values-v14
styles.xml 362B
drawable-hdpi
ic_launcher.png 9KB
drawable-xhdpi
ic_launcher.png 14KB
color
border.xml 246B
values
strings.xml 328B
styles.xml 637B
drawable-nodpi
photo5.jpg 512KB
photo2.jpg 325KB
photo7.jpg 146KB
photo1.jpg 293KB
photo6.jpg 423KB
photo3.jpg 300KB
photo4.jpg 432KB
drawable-mdpi
ic_launcher.png 5KB
layout
rounded_item.xml 2KB
picasso_item.xml 2KB
fragment_rounded.xml 529B
proguard-project.txt 781B
ic_launcher-web.png 74KB
src
com
makeramen
example
ColorFragment.java 3KB
RoundedFragment.java 4KB
ExampleActivity.java 1KB
PicassoFragment.java 4KB
AndroidManifest.xml 841B
build.gradle 581B
lint.xml 52B
pom.xml 4KB
NOTICE.txt 12KB
roundedimageview
pom.xml 3KB
res
values
attrs.xml 422B
proguard-project.txt 781B
src
com
makeramen
RoundedImageView.java 8KB
RoundedDrawable.java 11KB
AndroidManifest.xml 255B
build.gradle 2KB
gradle
wrapper
gradle-wrapper.jar 49KB
gradle-wrapper.properties 230B
screenshot.png 199KB
.gitignore 354B
screenshot-oval.png 194KB
README.md 4KB
settings.gradle 47B
build.gradle 330B
screenshot.png 199KB
共 49 条
- 1
资源评论
GJZGRB
- 粉丝: 1075
- 资源: 5911
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功