0

i want to round corner of my viewpager that it is a image slider

i try to use shape to round corner of constraint layout and viewpager and .. but it wasnt work i used card view but it wasnt work too

   <android.support.v7.widget.CardView
                android:layout_width="300dp"
                android:layout_height="200dp"
                android:layout_margin="20dp"
                app:cardCornerRadius="24dp"
                android:elevation="8dp"
                android:padding="1dp">
                <android.support.constraint.ConstraintLayout
                    android:id="@+id/slider_layout"
                    android:layout_width="299dp"
                    android:layout_height="199dp"
                    android:layout_gravity="center"
                    >

                    <android.support.v4.view.ViewPager
                        android:id="@+id/image_slider_view_pager"
                        android:layout_width="0dp"
                        android:layout_height="0dp"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintBottom_toBottomOf="parent"

                        />

                </android.support.constraint.ConstraintLayout>
            </android.support.v7.widget.CardView>

please

moslem
  • 69
  • 2
  • 9
  • Share image what you want. – Piyush Aug 19 '19 at 08:14
  • 1
    Possible duplicate of [How to Apply Corner Radius to LinearLayout](https://stackoverflow.com/questions/10074249/how-to-apply-corner-radius-to-linearlayout) – Mr. Patel Aug 19 '19 at 08:15
  • @Piyush i want app:cardCornerRadius="24dp" work on viewpager's images , corner of images be round – moslem Aug 19 '19 at 08:24
  • Post screenshot of what is happening with just using app:cardCornerRadius="24dp". Remove View pager insider cardview and see if corners are showing. – viv Aug 19 '19 at 08:26
  • @viv yes it work without viewpager – moslem Aug 19 '19 at 09:09

1 Answers1

1

you cannot round the viewPager, you just need to create a rounded rectangle (or any desired shape) drawable and set it as a background for the parent layout for each child fragment of the viewPager.

Sofien Touati
  • 91
  • 1
  • 4
  • how to round corner of image view? my viewpager templete is only an imageview – moslem Aug 19 '19 at 09:42
  • you can add the drawable background into your imageView, if it's all 4 corners are rounded otherwise you should use [Glide](https://github.com/bumptech/glide) and [Glide Transformations](https://github.com/wasabeef/glide-transformations) for the desired modification of the shape of your image – Sofien Touati Aug 19 '19 at 11:16