android - VideoView與百度Map沖突
問題描述
我在VideoView上面放了一個百度的MapView,如果視頻不播放的話,就是不調(diào)用VideoView的start方法,MapView能正常顯示,一旦調(diào)用start方法,MapView就會變黑,只顯示比例尺和縮放按鈕。布局文件如下:
<?xml version='1.0' encoding='utf-8'?>
<FrameLayout xmlns:android='http://schemas.android.com/apk/res/android'
android:layout_width='match_parent'android:layout_height='match_parent'><ImageView android: android:layout_width='match_parent' android:layout_height='match_parent' android:background='@drawable/saber'/><com.seawolf.test.FullScreeVideoView android: android:layout_width='match_parent' android:layout_height='match_parent' /><RelativeLayout android:layout_width='match_parent' android:layout_height='match_parent' android:paddingTop='@dimen/activity_vertical_margin'> <TextViewandroid: android:layout_width='wrap_content'android:layout_height='wrap_content'android:layout_gravity='left|center_vertical'android:text='yaw'android:layout_centerVertical='true'android:layout_alignParentStart='true' /> <TextViewandroid: android:layout_width='wrap_content'android:layout_height='wrap_content'android:layout_above='@id/yaw_text'android:text='pitch'/> <TextViewandroid: android:layout_width='wrap_content'android:layout_height='wrap_content'android:text='roll'android:layout_above='@id/pitch_text'/> <com.seawolf.test.NavControllerandroid: android:layout_width='wrap_content'android:layout_height='wrap_content'android:layout_alignParentBottom='true'android:layout_alignParentLeft='true'/> <com.baidu.mapapi.map.MapViewandroid: android:layout_width='120dp'android:layout_height='100dp'android:layout_alignParentBottom='true'android:layout_alignParentEnd='true'android:layout_alignTop='@+id/navController'android:background='@color/white'/></RelativeLayout>
</FrameLayout>
public void init() {back_image = (ImageView) findViewById(R.id.back_image);mController = new MediaController(this);mVideo = (VideoView) findViewById(R.id.video);File video = new File('/storage/sdcard1/hd.mp4');if(video.exists()){ mVideo.setVideoPath(video.getAbsolutePath()); // ① // 設(shè)置videoView與mController建立關(guān)聯(lián) mVideo.setMediaController(mController); // ② // 設(shè)置mController與videoView建立關(guān)聯(lián) mController.setMediaPlayer(mVideo); // ③ // 讓VideoView獲取焦點 // mVideo.requestFocus(); mVideo.setVisibility(View.INVISIBLE);}else Toast.makeText(MainActivity.this,'The Video is not exist.',Toast.LENGTH_SHORT).show();mMapView = (MapView) findViewById(R.id.map);mMapView.setVisibility(View.INVISIBLE);navController = (NavController) findViewById(R.id.navController);navController.setVisibility(View.INVISIBLE);navController.setOnNavAndSpeedListener(new NavController.OnNavAndSpeedListener() { @Override public void onNavAndSpeed(float nav, float speed) {Toast.makeText(MainActivity.this, 'nav is ' + nav + ',speed is ' + speed, Toast.LENGTH_SHORT).show(); }}); } private void videoStart() {mVideo.setVisibility(View.VISIBLE);mMapView.setVisibility(View.VISIBLE);navController.setVisibility(View.VISIBLE); // mVideo.start(); }
問題解答
回答1:VideoView和MapView都可以理解為SurfaceView。你可以給VideoView設(shè)置:setZOrderMediaOverlay(true);試試
參考:鏈接1鏈接2
相關(guān)文章:
1. bootstrp是col-md-12列的,只有col-md-10有內(nèi)容,可以讓沒有內(nèi)容的不占據(jù)位置嗎;2. 常量在外面不加引號會報錯。3. wordpress里,這樣的目錄列表是屬于小工具還是啥?4. android - Genymotion 微信閃退 not find plugin.location_google.GoogleProxyUI5. python如何設(shè)置一個隨著系統(tǒng)時間變化的動態(tài)變量?6. 百度地圖 - Android app中準(zhǔn)備接入地圖sdk,百度VS高德哪個好一點?7. 我的怎么不顯示啊,話說有沒有QQ群什么的8. mysql federated引擎無法開啟9. MySQL 使用 group by 之后然后 IFNULL(COUNT(*),0) 為什么還是會獲得 null10. sublime text3安裝package control失敗
