I have a viewpager which I use to display cards of offers, now, for some reason , when I click each card, it does not show me the progressbar I setup
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<ProgressBar
android:id="@+id/offer_progress"
android:layout_width="45dp"
android:layout_height="45dp"
android:indeterminate="true"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"/>
<ImageView
android:id="@+id/sliderImage"
android:layout_width="match_parent"
android:layout_height="200dp"/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
So, inside my viewpager fragment, I have a click for the image, and it should show the progress
sliderImage.setOnClickListener {
offer_progress.visibility = View.VISIBLE
}
but it does not show the progressbar
Any clue ?
try putting your Progressbar below ImageView.
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="@+id/sliderImage"
android:layout_width="match_parent"
android:layout_height="200dp"/>
<ProgressBar
android:id="@+id/offer_progress"
android:layout_width="45dp"
android:layout_height="45dp"
android:indeterminate="true"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>