I have a video thumbnail and when you click on it, the video starts playing in the YouTube player.
This works, but It's not clear that you have to click on the thumbnail to play, therefore, I want to draw a play button image over the thumbnail in the bottom right corner. How would I go about this?
I currently have the thumbnail in a Drawable object and the play button in my drawable resource directory.
I tried stuff with bitmaps and canvas but it's quite hard and I don't know if this is the way to go.
Layer list. A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top. Each drawable is represented by an <item> element inside a single <layer-list> element.
Multiple Views of an ImageYou can also set multiple views for an image in the same scene. The following program is an example that demonstrates how to set various views for an image in a scene in JavaFX. Save this code in a file with the name MultipleViews. java.
Use Relative or FrameLayout:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/thumbnail"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/play"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
or
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/thumbnail"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/play"
android:layout_gravity="bottom|right"/>
</FrameLayout>
What about using a FrameLayout
or a RelativeLayout
to stack the views..
Here follows some psaudo code:
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.yourpackage.VideoPlayer
android:layout_width="fill_parent"
android:layout_height="fill_parent"
></VideoPlayer>
<!-- Adjust the layout position of the button with gravity, margins etc... -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Play"
/>
</FrameLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With