android - ImageView 源始终覆盖其背景 Android
问题描述
我想将一侧设置为 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"/>
我也尝试在运行时添加图像后以编程方式设置背景,但它没有奏效。
谁能帮我找出解决方案?
解决方案
得到了解决方案。这对我来说很完美。
在您的项目级别 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。
推荐阅读
- git - 如何访问并提交到 github 上的远程分支
- vb.net - DataAdapter 不使用填充方法打开连接本身
- ios - AWS Cognito 用户组未显示
- python - 图像 src 没有完全刮掉。(../../../images/stat/popolazione.jpg)
- java - 在 Java 中使用 superfasthash
- reactjs - 摆脱“未定义”的 Typescript 错误,React
- reactjs - 使用 ReactJs 从 firebase 存储下载文件
- json - influxdb kapacitor 电报两个合作伙伴与 1 个机器人
- delphi - Delphi 似乎忽略了我的一些代码行?
- logging - 如果存在无法丢失的关键日志消息 (ALERT),syslog 如何通过 UDP 工作?日志消息顺序也很重要