Android 应用程序中的 VideoView 全屏

2024-03-20

我的应用程序中有一个视频视图。代码是这样的。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/opsbuds"
    android:orientation="vertical">

    <TextView
        android:id="@+id/adtxt1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView"></TextView>

    <VideoView
        android:id="@+id/videoView11"
        android:layout_width="300dip"
        android:layout_height="250dip"
        android:layout_marginLeft="30dip"></VideoView>

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

    <Button
        android:id="@+id/button1211"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/button"
        android:text=" Continue "
        android:textColor="#800080"
        android:textSize="20dp"
        android:textStyle="bold"></Button>
</LinearLayout>
</ScrollView>

xml 文件中提到了视频视图的宽度和高度。我想要的是,一旦我按下按钮,视频视图应该全屏显示,一旦我按下后退按钮,视频视图应该返回到其提到的大小。请帮忙?


我必须让我的 VideoView 位于relativelayout 中才能使所选的答案起作用。

<?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/videoViewRelative"
         android:layout_alignParentTop="true"
         android:layout_alignParentBottom="true"
         android:layout_alignParentLeft="true"
         android:layout_alignParentRight="true"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">
    </VideoView>
    
</RelativeLayout>

正如这里给出的:Android - 如何拉伸视频以填充VideoView区域 https://binhvova.wordpress.com/2013/04/23/android-how-to-stretch-video-to-fill-videoview-area/在屏幕尺寸之间切换就像更改所选答案中给出的布局参数一样简单。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android 应用程序中的 VideoView 全屏 的相关文章

随机推荐