Android landscape videoview on the center

android-layout

Solution

Try this code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:gravity="center">



         <VideoView android:id="@+id/videoview"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerInParent="true"/>

         <!-- Put Your Admob Layout here and it will work as you want. -->

</RelativeLayout>

Update

If you want to do it using Java code then refer to this.

Problem

i am developing android app. i need to play video in landscape mode and videoview should be in center of the screen, but it is playing the video in left corner of the screen. This is my code, ``` <VideoView android:id="@+id/videoView1" android:gravity="center" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" > ``` please help me. Thanks in advance.

Original source

Related problems