2014-07-15 3 views
0

비디오를 "배경"으로 표시하고 텍스트 및 기타보기를 FrameLayout을 사용하여 표시하는 앱을 개발 중입니다. .Immersive 모드가 활성화 된 상태에서 TextViews가 표시되지 않습니다. (Android)

어떤 이유로, 몰입 형 모드를 사용하면 시스템 탐색/상태 표시 줄을 표시 할 때 다시 나타나지만 테스트 할 때 사용하는 텍스트보기가 사라집니다.

public class MainActivity extends Activity{ 

    private Uri video; 
    private PowerManager.WakeLock wl; 
    private FrameLayout frame; 
    private TextView text; 
    private VideoView videoview; 
    private FrameLayout.LayoutParams layoutParams; 

    @SuppressWarnings("deprecation") 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     setContentView(R.layout.activity_main); 
     PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); 
     wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen"); 

     frame = (FrameLayout) findViewById(R.id.frame); 
     text = (TextView) findViewById(R.id.text_field_1); 
     videoview = (VideoView) findViewById(R.id.video_view); 

     resetDisplay(); 
     getWindow().setFormat(PixelFormat.UNKNOWN); 

     videoview.setOnPreparedListener(new OnPreparedListener(){ 
      @Override 
      public void onPrepared(MediaPlayer mp){ 
       mp.setLooping(true); 
      } 
     }); 

     video = Uri.parse(Environment.getExternalStorageDirectory()+"/video.avi"); 
     videoview.setZOrderOnTop(false); 
     videoview.setVideoURI(video); 
     videoview.start(); 
     text.bringToFront(); 

    } 


    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     // Handle action bar item clicks here. The action bar will 
     // automatically handle clicks on the Home/Up button, so long 
     // as you specify a parent activity in AndroidManifest.xml. 
     int id = item.getItemId(); 
     if (id == R.id.action_settings) { 
      return true; 
     } 
     return super.onOptionsItemSelected(item); 
    } 

    @Override 
    public void onWindowFocusChanged(boolean hasFocus) { 
     super.onWindowFocusChanged(hasFocus); 
     if (hasFocus) {} 

    } 

    protected void onPause(){ 
     super.onPause(); 
     videoview.suspend(); 
     wl.release(); 
    } 

    protected void onResume(){ 
     super.onResume(); 
     resetDisplay(); 
     videoview.start(); 
     wl.acquire(); 
    } 

    private void resetDisplay() 
    { 
     frame.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | 
       View.SYSTEM_UI_FLAG_FULLSCREEN | 
       View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | 
       View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | 
       View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | 
       View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | 
       View.SYSTEM_UI_FLAG_LOW_PROFILE); 

    } 

} 

그리고 내 레이아웃 XML :

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:clipChildren="false" 
    android:id="@+id/frame" 
    tools:context="com.example.exampleapp.MainActivity" > 

    <VideoView 
     android:id="@+id/video_view" 
     android:clickable="false" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:fitsSystemWindows="true"   
     /> 

    <TextView 
     android:id="@+id/text_field_1" 
     android:textColor="#FFFFFF" 
     android:textSize="25sp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/hello_world" /> 


</FrameLayout> 

사람이 비디오의 상단에 몰입 모드에 표시 할 텍스트를 강제하는 방법을 알고 있나요 여기

내 코드?

감사합니다. 당신의 텍스트 뷰의

android:layout_gravity 

속성을 설정

답변