Android VideoView全屏幕纵向显示

Android VideoView全屏幕纵向显示,android,android-videoview,Android,Android Videoview,请帮助我在纵向模式下全屏查看视频。我想在应用程序的启动页上全屏显示视频 这是我的密码。 我有一个填充宽度的视频视图,但高度只是屏幕中间的一部分。我希望视频视图填充整个宽度和高度 public class SplashFragment extends Fragment { public static final String TAG = SplashFragment.class.getSimpleName(); private FragmentInterface mFragmentInterfa

请帮助我在纵向模式下全屏查看视频。我想在应用程序的启动页上全屏显示视频

这是我的密码。 我有一个填充宽度的视频视图,但高度只是屏幕中间的一部分。我希望视频视图填充整个宽度和高度

public class SplashFragment extends Fragment {

public static final String TAG = SplashFragment.class.getSimpleName();
private FragmentInterface mFragmentInterface;
private VideoView mSplashVideoView;
private Uri mUri;

public SplashFragment() {
}

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    mFragmentInterface = (FragmentInterface) context;
}

@Override
public void onDetach() {
    super.onDetach();
    mFragmentInterface = null;
}

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mFragmentInterface.showActionBar(false);
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_splash, container, false);
    return view;
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    initView(view);
    initListener();
    playVideo();
}

@Override
public void onResume() {
    super.onResume();
    playVideo();
}

private void initView(View view) {
    mSplashVideoView = (VideoView) view.findViewById(R.id.splashVideoView);
    mUri = Uri.parse("android.resource://" + getActivity().getApplication().getPackageName() + "/" + R.raw.mylawmp4);
    mSplashVideoView.setMediaController(null);
    mSplashVideoView.setVideoURI(mUri);
}

private void initListener() {
    mSplashVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            displayScreens();
        }
    });
}

private void playVideo() {
    mSplashVideoView.setZOrderOnTop(true);
    mSplashVideoView.start();
}

private void displayScreens() {
    if (mFragmentInterface != null) {
        if (!PreferenceUtil.isLoggedIn(getActivity())) {
            mFragmentInterface.action(Constants.FragmentInterfaceConstants.ACTION_SEND_OTP, null);
        } else {
            mFragmentInterface.action(Constants.FragmentInterfaceConstants.ACTION_HOME, null);
        }
    }
}
}

Xml布局如下所示

   <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/splashScreen"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <VideoView
        android:id="@+id/splashVideoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:visibility="visible" /> </FrameLayout>

尝试将以下属性添加到xml布局中的
视频视图中:

 <VideoView 
     android:id="@+id/splashVideoView"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_alignParentLeft="true"
     android:layout_alignParentRight="true"
     android:layout_alignParentBottom="true"
     android:layout_alignParentTop="true"/>

嗯,我认为您必须编辑清单文件并在其中添加一些代码:


“我希望这能起作用”

试试这个:
android:layout\u gravity=“center\u horizontal | center\u vertical”
嘿,我有一个疑问……视频似乎被拉伸了。我们可以做些什么吗?或者我应该要求设计团队提供一个不同比例的视频,以适应不同的屏幕。请您的设计团队为您提供肖像视频(垂直视频)。