How to implement autohide task panel in android
I want to implement video panel in android in which i want to create a task panel which contain command such like play, pause. i have created a layout for this is
<?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"
android:id="@+id/layout">
<VideoView
android:id="@+id/videoView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView
android:id="@+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:textColor="@color/RED"
android:text="HI"></TextView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/rLayoutCameraButtons"
android:layout_gravity="center|bottom">
<SeekBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10px"
android:id="@+id/seekbar"
android:max="100"
android:layout_alignParentTop="true"
/>
<RelativeLayout
android:id="@+id/rlayout_buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/seekbar"
>
<Button
android:id="@+id/buttonPlay"
android:text="Play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
</Button>
<Button
android:layout_alignParentLeft="true"
android:id="@+id/buttonStop"
android:text="Stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button
android:id="@+id/buttonPause"
开发者_运维问答 android:text="Pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
</Button>
</RelativeLayout>
</RelativeLayout>
i want to hide auto hide my relative layout withing 5 sec from the last touch on that also i want to make it appear on touch on that area where it existed. not getting any idea plz help
Are you aware of MediaController
? If you don't need to customize your panel too much, it's the simple and elegant solution you're looking for. You can simply start with:
myVideoView.setMediaController(new MediaController(this));
Here's an example of the MediaController
being used in the 3D Gallery app.
May be ViewStub can be useful. Check it out if it fits in your requirement ...
http://developer.android.com/resources/articles/layout-tricks-stubs.html
One of the approaches that you can try:
1. Intercept the onTouchEvent
in your activity that hosts the player
2. on Touch Up post a delayed message to a Handler
created on UI thread, that will hide the parent layout of the panel.
3. Remember/determine the area where parent Layout of the panel is drawn. Inside on Touch, write a logic to decide if Touch occurred in area of interest, if so, make the panel visible.
Hope that helps.
精彩评论