ImageView 圆角 [英] ImageView rounded corners
本文介绍了ImageView 圆角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望图像具有圆角.我实现了这个 xml 代码并在我的图像视图中使用它.但图像重叠形状.我正在通过异步任务下载图像.
I wanted image to have rounded corners. I implement this xml code and use this in my image view. but image overlap the shape. I am downloading the image through async task.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="20dip" />
</shape>
<ImageView
android:id="@+id/trVouchersImage"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_marginLeft="8dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_alignParentLeft="true"
android:background="@drawable/ash_arrow"
/>
推荐答案
我使用 Universal Image loader 库来下载和圆角图像,它对我有用.
I use Universal Image loader library to download and round the corners of image, and it worked for me.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(thisContext)
// You can pass your own memory cache implementation
.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
.build();
DisplayImageOptions options = new DisplayImageOptions.Builder()
.displayer(new RoundedBitmapDisplayer(10)) //rounded corner bitmap
.cacheInMemory(true)
.cacheOnDisc(true)
.build();
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.init(config);
imageLoader.displayImage(image_url,image_view, options );
这篇关于ImageView 圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文