【发布时间】:2016-09-10 07:12:02
【问题描述】:
我有一个矩形图像,我想将其显示为圆形边框图像视图: 我做了一个这样的drawable:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="100dp" />
<solid android:color="#41ba7a" />
<stroke
android:width="3dip"
android:color="#f9f9f9" />
<padding
android:bottom="4dp"
android:left="4dp"
android:right="4dp"
android:top="4dp" />
</shape>
我在 ImageButton 中使用它:
<ImageButton
android:id="@+id/service_image_on_orderpage"
android:layout_width="120dp"
android:layout_height="120dp"
android:background="@drawable/profile_circular_border_imageview"
android:elevation="5dp"
android:padding="20dp"
android:scaleType="centerCrop"
android:layout_marginBottom="20dp"/>
看起来像这样:
但是当我将图像加载到其中时,它看起来像这样:
它没有完全覆盖 ImageButton。我希望加载的图片应该以圆形方式覆盖 ImageButton。
我尝试更改android:scaleType 的所有可能选项,但没有任何符合要求,我什至尝试将 ImageButton 更改为 ImageView 但问题仍然存在。
请帮忙。
【问题讨论】:
-
已经在这里回答了:stackoverflow.com/q/39423549/6816052
-
@NikunjParadva : 不能使用这个,因为我必须在项目的很多地方更改 ImageButton。
-
@Amit Upadhyay 而不是
ImageButton取ImageView为Nikunj说然后设置它。 -
@AmitUpadhyay 我认为圆形 Imagebutton 是不可能的,但使用 Imageview 我希望这个库对你有用
标签: android image bitmap imagebutton android-imagebutton