【发布时间】:2021-07-07 04:58:53
【问题描述】:
我正在尝试使用 wrap_content 的高度来实现微光效果,但图像没有加载,我知道为什么它没有加载图像,因为 imageView 有 wrap_content 并且微光也有 wrap_content 但我想要高度应该是 wrap_content 而不是固定的。
在微光中实现例如 200dp 的固定高度后,它可以工作,但之后图像不会加载
我想让它像 Pinterest 一样,根据图像调整高度
XML 文件
post_item_container_search.xml
<com.google.android.material.imageview.ShapeableImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imagePostSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="11dp"
android:layout_marginEnd="6dp"
android:contentDescription="@string/todo"
app:shapeAppearanceOverlay="@style/RoundedCorner" />
post_item_containe_shimmer.xml
<com.google.android.material.imageview.ShapeableImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/imageShimmer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="11dp"
android:layout_marginTop="11dp"
android:background="#E7E7E7"
android:contentDescription="@string/todo"
app:shapeAppearanceOverlay="@style/RoundedCorner" />
将 minHeight 添加到两者或实际 imageView 后的样子
【问题讨论】:
-
@SagarRawal 这可能是因为您的 imageview 没有确定的大小,例如尝试将您的 imageview 高度更改为 48dp。
-
@YaMiN 你的意思是我必须在图像视图或微光 XML 中更改大小?
-
@YaMiN 好的,我尝试将微光高度设置为 200dp,微光正在工作,但之后图像没有加载我知道为什么现在但问题是我必须使图像高度 wrap_content 因为我想让它像 Pinterest 一样根据法师高度调整高度,所以如果我修复图像高度,我将无法获得可调整高度元素
-
你是在尝试 recyclerView 中的微光效果
标签: java android android-recyclerview android-animation placeholder