Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在纵向模式下居中显示视频_Java_Android - Fatal编程技术网

Java 在纵向模式下居中显示视频

Java 在纵向模式下居中显示视频,java,android,Java,Android,我有一个在视频视图中显示视频的应用程序 当我的应用程序处于横向模式时,视频会全屏显示,这很好。 当我将videoview置于纵向模式时,视频的宽度就是屏幕的宽度,而高度是可缩放的 这里的问题是视频视图显示在屏幕顶部。我想让它显示在屏幕中央 <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2009 The Android Open Source Project Licensed under the A

我有一个在视频视图中显示视频的应用程序

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

这里的问题是视频视图显示在屏幕顶部。我想让它显示在屏幕中央

<?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>

如何在纵向模式下将视频视图居中对齐?

将其放入视频视图中

android:layout_centerInParent="true"

也许android:layout\u centerInParent=true'?然后,我将在LinearLayout:layout\u CenterInParents中获取无效的layout参数,并将其切换到一个RelativeLayout中。@RobertVerkerk-如果您不喜欢某个答案,您应该对其进行评论或否决,而不是将其标记为删除。旗帜应该保留给那些显然不是试图回答的东西,或者只包含一个链接的东西。@ArtOfWarfare我没有旗帜it@Tardo我会试试tommorow,而不是工作时的pc atm。当/如果有效,将评论/接受: