rk android
rk android

Reputation: 25

how to set width and height of YouTube API?

we are using YouTube API for showing YouTube videos in our apps , it is working fine and we have done some customisation with it .we are using YouTubePlayer.PlayerStyle.CHROMELESS to hide every control and have created our own control which works fine with YouTube api .

problem is that we are not able to see full width video from youtube in landscape mode . there are blank side bar on left and right of video , it works fine in tablet and but it does not work well with phones because device is taller when user rotates phone to landscape video height fills the height of screen but video only appears in centre here is the example .

here right now we are getting video like this

enter image description here

but we want it to fill full screen of phone width like below

enter image description here

here is layout of YouTube API activity

 <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtube_player_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/video_player_console"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"/>

we have already tried following things .

i am thinking to convert video view into Bitmap and than fill screen like we can do with image but i think it is not possible with video because we do not have video file cause it is coming from you tube and second thing is that , this solution only works with image not with video .

if any one have idea how can i make it full width video suggest us .

Upvotes: 0

Views: 625

Answers (1)

Francesco Bocci
Francesco Bocci

Reputation: 867

use wrap_content :

 <com.google.android.youtube.player.YouTubePlayerView
    android:id="@+id/youtube_player_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@id/video_player_console"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"/>

Upvotes: 1

Related Questions