RoundedImageView
================
A fast ImageView (and Drawable) that supports rounded corners based on the original [example from Romain Guy](http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/)

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
* 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 TransitionDrawables (XML attrs only)
Import Library
----
Import Library: `RoundedImageView/library/`
Maven
----
Execute this in your workspace:
```
git clone https://github.com/kolipass/RoundedImageView.git
cd ./RoundedImageView/
mvn clean install
```
To run example:
````
cd ./example
mvn android:deploy android:run
````
Add this dependency:
```
<dependency>
<groupId>com.makeramen.rounded</groupId>
<artifactId>library</artifactId>
<version>0.1</version>
<type>apklib</type>
</dependency>
```
Use Library
----
Define in xml:
```xml
<com.makeramen.rounded.RoundedImageView
xmlns:makeramen="http://schemas.android.com/apk/res/com.makeramen.rounded.RoundedImageView"
android:id="@+id/imageView1"
android:src="@drawable/photo1"
android:scaleType="centerCrop"
makeramen:corner_radius="30dip"
makeramen:border="2dip"
makeramen:border_color="#333333"
makeramen:round_background="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);
```
Known Issues
--------------------------------------
* Does not round images set by `setImageResource(int resId)`. This causes bitmaps to be inflated on the UI thread anyway, so you should use `setImageDrawable` or `BitmapFactory` and `setImageBitmap()` instead.
* Programmatically setting attributes with TransitionDrawables not yet supported.
* Only tested support for BitmapDrawables and TransitionDrawables (with BitmapDrawables in them). Other types might work but may have unexpected behavior.
小程序源码 RoundedImageView-master.zip
版权申诉
112 浏览量
2023-03-19
20:37:21
上传
评论
收藏 2.95MB ZIP 举报

荣华富贵8
- 粉丝: 89
- 资源: 7046
最新资源
- 源.c
- 折线图.py
- 戴尔DELL AlienWare M11X - LA-5812P NAP10 - REV 1.0.pdf
- java之企业开发辅助
- FIC代工的最新笔记本主板图纸-PCA50D-CALPELLA-V02-P.pdf
- 嵌入式比赛.zip 嵌入式比赛.zip 嵌入式比赛.zip 嵌入式比赛.zip 嵌入式比赛.zip 嵌入式比赛.zip
- 戴尔 i7i5i3笔本图纸FIC代工的最新笔记本主板图纸-PCA50-V1.2-1230-.pdf
- 戴尔 i7i5i3笔本图纸,FIC代工的最新笔记本主板图纸-pca50-v1.0-1106-1050.pdf
- java各种面试资源大全
- 惠普笔记本电脑i系列图纸
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


