全屏VideoView不集中 [英] Fullscreen VideoView isn't Centered

查看:100
本文介绍了全屏VideoView不集中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个XML布局上显示我的活动全屏VideoView。视频是全屏但它不居​​中。在横向模式下,它停留在屏幕的左侧和叶子在屏幕的右侧一些空格。

怎样才能使我的VideoView置于画面的中心?

 <?XML版本=1.0编码=UTF-8&GT?;
 <的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
           机器人:layout_width =FILL_PARENT
           机器人:layout_height =FILL_PARENT>
   < VideoView机器人:ID =@ + ID / myvideoview
             机器人:layout_width =FILL_PARENT
             机器人:layout_alignParentRight =真
             机器人:layout_alignParentLeft =真
             机器人:layout_alignParentTop =真
             机器人:layout_alignParentBottom =真
             机器人:layout_height =FILL_PARENT>
    < / VideoView>
 < / RelativeLayout的>


解决方案

试试这个布局,

 <?XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的
  的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
  机器人:layout_width =WRAP_CONTENT
  机器人:layout_height =WRAP_CONTENT
  机器人:layout_gravity =中心
  机器人:比重=中心>         < VideoView机器人:ID =@ + ID / videoview
         机器人:layout_width =WRAP_CONTENT
         机器人:layout_height =WRAP_CONTENT
         机器人:layout_centerInParent =真/>< / RelativeLayout的>

I use this XML layout to show a fullscreen VideoView on my activity. The Video is fullscreen but it isn't centered. In landscape mode, it stays on the left side of the screen and leaves some blank spaces on the right side of the screen.

How can I make my VideoView placed in the center of the screen?

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" >
   <VideoView android:id="@+id/myvideoview"
             android:layout_width="fill_parent"
             android:layout_alignParentRight="true"
             android:layout_alignParentLeft="true"
             android:layout_alignParentTop="true"
             android:layout_alignParentBottom="true"
             android:layout_height="fill_parent">
    </VideoView>
 </RelativeLayout>

解决方案

Try this layout,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"              
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:gravity="center">



         <VideoView android:id="@+id/videoview"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerInParent="true"/>

</RelativeLayout>

这篇关于全屏VideoView不集中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆