我想将一侧舍入为ImageView
因此,我已将其作为背景添加到ImageView
one_rounded_side.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="200.0"
android:viewportHeight="100.0">
<path
android:fillColor="#000"
android:pathData="M200,0H0v4.5h0v75.8h0c17.8,10.2 56,17.2 100.5,17.2c44.5,0 81.6,-7 99.5,-17.2h0V4.5h0V0z" />
并在运行时将图像设置为ImageView,但是我设置的图像始终会覆盖此背景可绘制对象。因此它显示为普通矩形。
我已经这样添加了ImageView
<ImageView
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@drawable/one_rounded_side"
android:scaleType="centerCrop"/>
我也尝试过在运行时添加图像后以编程方式设置背景,但是没有用。
有人可以帮助我找出解决方案吗?
答案 0 :(得分:-1)
有解决方案。这对我来说很完美。
在您的项目级别build.gradle中包含以下代码
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
在应用程序级别build.gradle中包含以下代码
implementation 'com.github.developer-shivam:Crescento:1.2.1'
将此内容包含在您的xml文件中
<developer.shivam.crescento.CrescentoContainer
android:id="@+id/crescentoContainer"
android:layout_width="match_parent"
android:layout_height="250dp"
android:elevation="1dp"
android:scaleType="centerCrop"
attribute:curvature="50dp">
<ImageView
android:id="@+id/iv_news_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>
</developer.shivam.crescento.CrescentoContainer>
并在运行时将图像设置为ImageView。