【发布时间】:2013-04-17 23:04:04
【问题描述】:
我尝试拉伸视频以填充视频视图。目标是创建在设备中看起来像第一张图片的视图(就像它在布局预览中的样子)。
这个问题的大部分答案都参考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会相对于其中播放的视频进行收缩/拉伸。 -
好的,所以我需要更改媒体记录器的纵横比意味着添加 mMediaRecorder.setVideoSize(640, 480);我试试这个,它不起作用...... ???
标签: android android-videoview aspect-ratio