Search code examples
androidandroid-youtube-api

Android: How to add play button on YouTubeThumbnailView


I have implemented youtubeThumnailView without any problem.

Currently my thumbnail view looks like this on an android phone: enter image description here

But how do i add a play button on the thumbnail view like this https://lh4.googleusercontent.com/-c06CilFxXA8/TW3qUN4WTBI/AAAAAAAAAIU/6UaNpVuAt5w/s1600/webView+with+play+button.png


Solution

  • You need to:

    1. put your youtubeThumnailView in Layout (ex. RelativeLayout)

    2. add Button or ImageView over your youtubeThumnailView

    example:

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
    
            <!-- ImageView or your youtubeThumnailView -->
            <ImageView
                android:id="@+id/iv_youtube_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scaleType="fitCenter"
                android:src="@drawable/profile_img_default" />
    
            <!-- ImageView of your button -->
            <ImageView
                android:id="@+id/iv_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/profile_img_capture" />
    
        </RelativeLayout>