现在的位置: 首页 > 综合 > 正文

Custom MediaCotroller|自定义视频控制栏

2013年12月12日 ⁄ 综合 ⁄ 共 2900字 ⁄ 字号 评论关闭
文章目录

一、编写XML

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="fill_parent" android:layout_height="fill_parent">
	<RelativeLayout android:id="@+id/View_Screen"
		android:orientation="vertical" android:layout_width="wrap_content"
		android:layout_height="wrap_content">
		<com.enleo.android.player.Surface.TappableSurfaceView android:id="@+id/View_Surface"
			android:layout_width="fill_parent" android:layout_height="fill_parent">
		</com.enleo.android.player.Surface.TappableSurfaceView>
	</RelativeLayout>

	<RelativeLayout android:layout_width="fill_parent"
		android:layout_height="fill_parent">
		<LinearLayout android:id="@+id/TopPanel_View" android:orientation="horizontal" 
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_alignParentTop="true" android:layout_marginTop="5dip"
			android:background="#e0000000">
			<TextView android:id="@+id/CurrentTimeTextView"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:layout_gravity="center_vertical" android:text="--:--" />
			<SeekBar android:id="@+id/Seek_Bar" android:layout_width="wrap_content"
				android:layout_height="wrap_content" android:paddingLeft="5dip"
				android:paddingRight="5dip" android:layout_marginLeft="10dip"
				android:layout_marginRight="10dip" android:layout_weight="1" />
			<TextView android:id="@+id/TotalTimeTextView"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:layout_gravity="center_vertical" android:text="--:--" />
		</LinearLayout>
		<LinearLayout android:orientation="horizontal" android:id="@+id/BottomPanel_View"
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_alignParentBottom="true" android:background="#e0000000">
			<ImageButton android:id="@+id/btn_File"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:src="@drawable/file" android:layout_gravity="center_vertical"
				android:layout_weight="1" android:background="#00000000"
				android:text="File" />
			<ImageButton android:id="@+id/btn_Start"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:src="@drawable/play" android:layout_gravity="center_vertical"
				android:layout_weight="1" android:background="#00000000"
				android:text="Start" />
			<ImageButton android:id="@+id/btn_Pause"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:layout_gravity="center_vertical" android:layout_weight="1"
				android:src="@drawable/pause" android:background="#00000000"
				android:text="Pause" />
			<Button android:id="@+id/btn_Full"
				android:layout_width="wrap_content" android:layout_height="wrap_content"
				android:layout_gravity="center_vertical" android:layout_weight="1"
				android:text="FULL"
			/>
		</LinearLayout>
	</RelativeLayout>
</FrameLayout>

** 注意:FrameLayout

二、控制栏的显示和隐藏

topPanel.setVisibility(View.VISIBLE);
bottomPanel.setVisibility(View.VISIBLE);

topPanel.setVisibility(View.GONE);
bottomPanel.setVisibility(View.GONE);

抱歉!评论已关闭.