以纵向模式居中视频

时间:2014-11-20 15:09:29

标签: java android

我有一个应用程序,可以在视频视频中显示视频。

当我的应用程序处于横向模式时,视频显示全屏,这很好。 当我将视频视图置于纵向模式时,视频的宽度就是屏幕的宽度,而且高度也很好。

这里的问题是视频视图显示在屏幕顶部。我希望它显示在屏幕中间(居中)。

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android">
    <FrameLayout android:id="@+id/fullscreen_custom_content"
        android:visibility="gone"
        android:background="@color/black"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
    />
    <LinearLayout android:id="@+id/linearlayout"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout android:id="@+id/error_console"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" />

        <!--  webview will be put in the next framelayout -->

        <FrameLayout 
            android:id="@+id/main_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
        />

       <VideoView
           android:id="@+id/surface_vie"
           android:layout_width="match_parent"
           android:layout_height="match_parent"/>
    </LinearLayout>
</FrameLayout>

如何在纵向模式下将视频视频对准中心?

1 个答案:

答案 0 :(得分:0)

将其置于VideoView

android:layout_centerInParent="true"