创建ImageView的带圆角 [英] Creating ImageView with round corners
问题描述
如何创建一个的ImageView
一个带有边框和圆角?
How would i create a ImageView
with a border and round corners?
我想了的ImageView
是圆的,我试图创造一个形状绘制与中风和圆角作为背景绘制的的角落ImageView的
但这并没有给出正确的效果,因为图像被填充的容器内,并没有填写的边界的边缘。
I want to corners of the ImageView
to be round, i tried creating a shape drawable with a stroke and round corners as background drawable of the ImageView
but that doesn't give the right effect, because the image is padded inside the container and does not fill out to the edge of the borders.
推荐答案
我知道这个工程上的LinearLayout,但我不知道它的工作原理上imageviews,值得一试,你可以做这样的事情的背景
i know this works on LinearLayout, but i'm not sure it works on imageviews , worth a try ,you could do something like this on the background
让您的ImageView会是这个样子,也许
so your imageview would look something like this maybe
<ImageView android:background="@drawable/rounded"/>
如果你调用这个文件rounded.xml什么
if you call this file rounded.xml or something
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp" android:topRightRadius="10dp"/>
<stroke
android:color="@drawable/black"
android:width="1dp"
/>
</shape>
此页面是一个很好的参考 http://developer.android。 COM /引导/主题/资源/绘制-resource.html
this page is a good reference http://developer.android.com/guide/topics/resources/drawable-resource.html
这篇关于创建ImageView的带圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!