0

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 ?

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
SNM
  • 5,625
  • 9
  • 28
  • 77

1 Answers1

1

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>
Parth
  • 791
  • 7
  • 17
  • @Froyo The problem was imageView overlapping the ProgressBar. Hence ProgressBar was there but not visible on the screen. That's why i asked to put ProgressBar below the imageView. – Parth Apr 08 '20 at 16:41