2016-09-29 23 views
-3

當播放視頻全屏,其他視圖在佈局中消失,但getVisibility()回到VISIBLEisShown()回到true。 誰遇到同樣的問題,或者有很好的解決方法,請告訴我,謝謝。View是無形

這是activity_player.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/player" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/white"> 

<!--Used to play the video--> 
<com.mediaplay.MySurfaceView 
    android:id="@+id/videoView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

<!--Used to play the marquee--> 
<com.mediaplay.AutoScrollTextView 
    android:id="@+id/marqueeView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:textColor="@android:color/black" 
    android:textSize="23sp" 
    /> 
    </RelativeLayout> 

它的代碼(代碼是太多了,我只能捕捉重要組成部分):

// play video 
public void start() { 
    if (mMediaPlayer != null && mIsPrepared) { 
     LOG("MediaPlayer start"); 
     mMediaPlayer.start(); 
    } 
} 

// play marquee, it extends TextView 
private void initTextView() { 

    if (marquee == null) return; 

    marquee.requestFocus(); 
    marquee.setSelected(true); 
    marquee.bringToFront(); 
    marquee.startScroll(); 
} 

public void startScroll() { 
    isStarting = true; 
    invalidate(); 
} 
  1. 我嘗試使用的FrameLayout相反,它不不工作
  2. 這裏有一些奇怪的事情,當顯示吐司或彈出式對話框時,marqueeview可以顯示,但一旦消失,marqueeview就會消失。
  3. 有一件事是肯定的,不要調用mediaplayer.start(),marqueeview可以顯示,但一旦調用,它會消失。
  4. Android4.2.2沒有probleams,android4.4.4將有probleams
+1

有些代碼會更好看,你知道...:/ –

+0

@Victor:如果你使用FrameLayout,請發佈一些代碼和(豎起大拇指),那麼你的視圖可能已經在背景中,所以嘗試,YOUR_VIEW。 bringToFront(); – Pawan

回答

0

也許他們不會消失,但是視頻簡直是比其他的看法?您可以使用相對佈局來確保視圖覆蓋視頻。

雖然代碼會很好。

+0

我已經使用了相對佈局,並且我發現了一些奇怪的東西,當顯示敬酒或彈出對話框時,視圖可以顯示,並且我已經調用了bringToFront(),它不起作用 – Victor