android – 扩展VideoView,VideoView的宽高比

我试图拉伸视频,以填补视频.目标是创建在设备中看起来像第一个图片(如在布局预览中看起来)的视图.

这个问题的大部分答案是this link.

我试过这个,但我还是没有填写视频观看.

这个我的布局代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="@drawable/search_gren_screen">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/go_back"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:onClick="onclick"
            android:text="Try again" />

        <Button
            android:id="@+id/back_to_pick_song"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Select another song" 
            android:onClick="onclick" />

        <Button
            android:id="@+id/btn_continue"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:onClick="onclick"
            android:text="Amazing,continue!" />
    </LinearLayout>

    <FrameLayout 
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
    <VideoView 
        android:id="@+id/videoView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_gravity="center" />
    </FrameLayout>
</LinearLayout>

在这里,您可以预览我声明的布局:

但是,设备上的结果是不同的:

解决方法

尝试使您的外部布局相对布局,并将VideoView放在其中.

就像是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/trim_container"
     android:layout_width="match_parent"
     android:layout_height="match_parent" >

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

     <Button
          android:id="@+id/go_back"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_gravity="center"  
          android:layout_weight="1"
          android:onClick="onclick"
          android:text="Try again" />

     <Button
          android:id="@+id/back_to_pick_song"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="1"
          android:text="Select another song" 
          android:onClick="onclick" />

    <Button
          android:id="@+id/btn_continue"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:layout_weight="1"
          android:onClick="onclick"
          android:text="Amazing,continue!" />
  </LinearLayout>

  <VideoView
     android:id="@+id/VideoView"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_alignParentLeft="true"
     android:layout_alignParentRight="true"
     android:layout_alignParentBottom="true"
     android:layout_below="@id/buttonContainer"/>
</RelativeLayout>

相关文章

Android 通过adb shell命令查看内存,CPU,启动时间,电量等...
Monkey Android app稳定性测试工具之Monkey使用教程 by:授客...
Android 常见adb命令 by:授客 QQ:1033553122 1、 查看所有已...
这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...