我正在尝试使用Google+应用显示用户照片的椭圆形照片。
我有一个像这样的ImageView:
<ImageView
android:id="@+id/iv_user_photo"
android:layout_width="80dp"
android:layout_height="80dp"
android:background="@drawable/user_photo_shape"/>
可绘制的背景是:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="#FFFFFF" />
<stroke android:width="1dp" android:color="#000000" />
<padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" />
</shape>
我的问题是当我使用setImageBitmap将图像设置为ImageView时,矩形图像在背景上绘制,并且不限于椭圆边框。我试过“AdjustViewBounds = true”,但它没有改变任何东西。你知道我怎么能实现这个目标吗?
答案 0 :(得分:1)
我刚刚使用Romain Guy博客的post代码找到了解决方案。
答案 1 :(得分:0)
我之前没有这样做,但此链接显示了如何使用PorterDuffXfermode屏蔽掉。