I am trying to make a VideoView stretch on the whole screen. I have the following layout xml in my project:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
tools:context="com.example.myproject.MainActivity"
android:background="@color/green">
<VideoView
android:id="@+id/videoView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
However, the phone screen looks like this (the background color is green and the width does stretch properly):
Also android:
layout_height="fill_parent" and
layout_height="match_parent"
produces the same result. The phone runs Android 4.4. Also, the theme used is Theme.Holo.Light.NoActionBar, but changing the theme produces the same result (even though the xml preview includes the respective bars). I also remove the title and action bar in the main activity. Here is my MainActivity.java OnCreate() method (this is the only thing I have changed):
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
final VideoView videoPlayer = (VideoView)findViewById(R.id.videoView);
videoPlayer.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.zp);
videoPlayer.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
videoPlayer.start();
return false;
}
});
}
Can anybody please tell me how can I make the VideoView stretch on the whole screen?