使用setImageBitmap而不更改ImageButton的形状

时间:2018-03-17 08:28:39

标签: java android bitmap android-imagebutton

我的相机应用程序有一个圆形的ImageButton,用于显示用户像许多其他相机应用程序一样捕获的最后一个图像。为了给ImageButton一个圆形的形状我正在使用一个使用drawable作为背景的样式,我使用ImageButton的setImageBitmap函数来显示图像拇指。但问题是在设置位图后,ImageButton的形状会变为方形。如何在不改变ImageButton形状的情况下做到这一点?

1 个答案:

答案 0 :(得分:0)

您可以使用circular Image view库来实现

<CircularImage.CircleImageView
                android:id="@+id/profilecircularimage"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_centerVertical="true"
                android:layout_gravity="center_vertical|center_horizontal"
                android:layout_marginTop="10dp"
                android:clickable="true"
                android:src="@drawable/cameraImage"
                app:civ_border_color="@color/primary"
                app:civ_border_width="2dp" />
相关问题