Reputation: 189
I have an ImageView
, and below it, there is a TextView
. Both are inside a ConstraintLayout
.
The ImageView
can display either a GIF
or a normal image
.
The TextView
appears fine when I use a normal image in the ImageView
, but it gets hidden when displaying a GIF
.
Code :
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="@dimen/new_dimen_350_dp"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvTermsAndCondition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dimen_16_dp"
android:layout_marginBottom="@dimen/dimen_16_dp"
android:elevation="1dp"
android:fontFamily="@font/roboto_medium"
android:paddingBottom="@dimen/dimen_2_dp"
android:shadowColor="@color/black"
android:shadowDx="0"
android:shadowDy="2"
android:shadowRadius="1"
android:translationZ="1dp"
android:text="@string/t_c_apply"
android:textColor="@color/white"
android:textSize="@dimen/txt_smallX"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="@+id/imageView" />
Kotlin Code
if(mediaType == MediaType.TYPE_IMAGE) {
Glide.with(binding.imageView.context).load(bannerUrl)
.into(binding.imageView)
}
else if (mediaType == MediaType.TYPE_GIF){
Glide.with(binding.imageView.context)
.asGif()
.load(bannerUrl)
.into(binding.imageView)}
Upvotes: 0
Views: 43