面膜的ImageView与圆角背景 [英] Mask ImageView with round corner background
问题描述
我有一个自定义列表视图
包含的ImageView,TextView中
一切工作正常。
我要的是图像会显示在列表中的圆角。从WebService我得到的矩形形状的图像。但我想,如下图所示圆角ImageView的显示出来。
谁能告诉我我怎么能掩盖圆角图片的方式吗?
我已经尝试过通过创建可绘制文件如下,并将其应用为SRC的ImageView的。但没有为我工作。
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目>
<形机器人:形状=椭圆形>
[固体机器人:颜色=#FFFFFF/>
<填充
机器人:底部=10dp
机器人:左=10dp
机器人:右=10dp
机器人:顶部=10dp/>
<边角机器人:半径=5DP/>
< /形状>
< /项目>
<项目>
<形机器人:形状=椭圆形>
<填充
机器人:底部=5DP
机器人:左=5DP
机器人:右=5DP
机器人:顶部=5DP/>
[固体机器人:颜色=#FFFFFF/>
< /形状>
< /项目>
< /层列表>
编辑:
请帮我。
任何帮助将AP preciated。
感谢
我已经申请如下解决方案:
<的FrameLayout
机器人:ID =@ + ID / imagemaskframe
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:填充=10dp>
< ImageView的
机器人:ID =@ + ID / op_ivpic
机器人:layout_width =80dp
机器人:layout_height =80dp
机器人:layout_gravity =中心
机器人:scaleType =fitXY/>
< ImageView的
机器人:ID =@ + ID / iv_mask_op
机器人:layout_width =80dp
机器人:layout_height =80dp
机器人:layout_gravity =中心
机器人:adjustViewBounds =真
机器人:scaleType =fitXY
机器人:SRC =@可绘制/ imgmask/>
< /的FrameLayout>
我建议你用另外一种方法:
一的FrameLayout
和两个的ImageView
能做到这一点。
<的FrameLayout>
< ImageView的/>把它有一个透明圈中有一个形象
< ImageView的/>你的形象
< /的FrameLayout>
那么你的图像可以通过透明圈被看见。
I am having a Custom Listview
which contains the ImageView, TextView
Everything is working fine.
What i want is the image is displayed in list are in round corner. From the Webservice i get the images in rectangle shape. But i want to display it in Round corner ImageView as below.
Can anyone show me the way how can i mask the image in round corner?
I already tried by creating the drawable file as below and applied it as src in imageview. But nothing working for me.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="oval" >
<solid android:color="#FFFFFF" />
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
<corners android:radius="5dp" />
</shape>
</item>
<item>
<shape android:shape="oval" >
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<solid android:color="#FFFFFF" />
</shape>
</item>
</layer-list>
EDITED:
Please help me.
Any help will be appreciated.
Thanks
I have Applied below solution:
<FrameLayout
android:id="@+id/imagemaskframe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp" >
<ImageView
android:id="@+id/op_ivpic"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:scaleType="fitXY" />
<ImageView
android:id="@+id/iv_mask_op"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/imgmask" />
</FrameLayout>
i suggest you to use another method:
One FrameLayout
and two ImageView
can do it.
<FrameLayout>
<ImageView /> put a image which has a transparent circle in it
<ImageView /> your image
</FrameLayout>
then your image can been seen via transparent circle.
这篇关于面膜的ImageView与圆角背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!