How do I redefine VideoView onDraw so that it has transparent rounded corners?

Obviously, using the background shape does not work in the case of VideoView. In addition, there are many articles on how to override onDraw for ImageView and make its corners round.

But how to do it for VideoView?

+1
source share
3 answers

Transparent rounded corners cannot be made using VideoViewor any SurfaceViewas specified in the documentation:

Surface Z is ordered so that it is outside the window holding SurfaceView; SurfaceView punches a hole in its window so that its surface displays.

a TextureView , . : Porter Duff TextureView, ShapeDrawable FrameLayout.

VideoView . 9- ImageView, .

: .

screenshot

+6

, . , :

  • ImageView
  • ImageView PNG, .
  • FrameLayout RelativeLayout, , .
0

You can easily achieve this effect by putting TextureView inside CardView (from the support library).

Then you can set the radius and shadow on the CardView:

<androidx.cardview.widget.CardView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:cardCornerRadius="12dp">

    <TextureView
        android:id="@+id/video"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</androidx.cardview.widget.CardView>
0
source

All Articles