Vitamio自定义控制器MediaController样式

本文展示了如何自定义Vitamio的MediaController,添加额外的菜单并调整视频名称的显示位置。提供了自定义布局文件mymdiacontroller的代码示例以及在Activity中的使用方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

先看一下效果图


比自带控制器多出上面菜单,并将视频名称改到上面显示


先是布局文件 mymdiacontroller

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="34dp"
            android:background="#77000000">

            <ImageButton
                android:id="@+id/mediacontroller_top_back"
                android:layout_width="50dp"
                android:layout_height="match_parent"
                android:layout_alignParentStart="true"
                android:background="@null"
                android:src="@drawable/left_white_arrow"/>

            <TextView
                android:id="@+id/mediacontroller_file_name"
                style="@style/MediaController_Text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_marginLeft="5dp"
                android:ellipsize="marquee"
                android:singleLine="true"
                android:text="file name"/>

            <TextView
                android:id="@+id/mediacontroller_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="5dp"
                android:text="17:22"
                android:textColor="#ffffff"
                android:textSize="15sp"/>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/rl_med"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_alignParentBottom="true"
            android:background="#77000000">

            <ImageButton
                android:id="@+id/mediacontroller_play_pause"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                and
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值