我正在尝试将视频视图放在导航抽屉里面。 VideoView工作正常但在导航抽屉快速移动时冻结,并且视频也不能快速移动导航抽屉。是否有任何想法来解决这个问题?????请帮助:::
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/drop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true" >
</FrameLayout>
<RelativeLayout
android:id="@+id/left_drawer"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#00000000"
android:choiceMode="singleChoice"
android:dividerHeight="1dp"
android:paddingRight="1dp" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="280dp"
android:layout_height="150dp"
android:layout_centerHorizontal="true" />
</RelativeLayout>
这是我的活动::::
public class MainAct extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.vid);
VideoView videoView= (VideoView) contentView.findViewById(R.id.videoView1);
videoView.setVideoPath("/sdcard/x.mp4");
videoView.start();
}
}
提前致谢....
答案 0 :(得分:0)
您可以尝试在导航栏上设置drawerListener,并根据抽屉状态暂停和恢复视频视图。这样的事情应该有效:
mDrawerLayout.setDrawerListener(new DrawerListener() {
@Override
public void onDrawerStateChanged(int arg0) {
// TODO Auto-generated method stub
}
@Override
public void onDrawerSlide(View arg0, float arg1) {
// TODO Auto-generated method stub
}
@Override
public void onDrawerOpened(View arg0) {
// TODO Auto-generated method stub
myVideoView.pause();
}
@Override
public void onDrawerClosed(View arg0) {
// TODO Auto-generated method stub
myVideoView.resume();
}
});