【问题标题】:Center video in portrait mode以纵向模式居中视频
【发布时间】:2014-11-20 15:09:28
【问题描述】:

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

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

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

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

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

【问题讨论】:

标签: java android


【解决方案1】:

把它放在你的 VideoView 中

android:layout_centerInParent="true"

【讨论】:

  • 然后我会在 LinearLayout 中得到 Invalid layout param: layout_centerInParent
  • 切换到RelativeLayout。
  • @RobertVerkerk - 如果您不喜欢某个答案,您应该对其发表评论或投反对票,而不是将其标记为删除。标志应该保留给那些显然不是试图回答的事情,或者只包含一个链接的事情。
  • @ArtOfWarfare 我没有举报
  • @Tardo 明天将尝试,而不是在工作 pc atm。将评论/接受何时/如果有效:)
猜你喜欢
  • 2012-08-13
  • 2012-11-04
  • 2011-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-27
  • 1970-01-01
相关资源
最近更新 更多