2013-05-15 3 views
0

안녕하세요. 방향 변경을 재생할 때이 문제가 있습니다. 세로로 보면 레이아웃 디렉토리에 다음 XML이 있습니다. VideoView 방향이 전체 화면으로 변경됨 (동작 표시 줄 및 알림 표시/숨기기)

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <!-- Player Header --> 
    <LinearLayout 
     android:id="@+id/player_header_bg" 
     android:layout_width="fill_parent" 
     android:layout_height="60dip" 
     android:background="@layout/bg_player_header" 
     android:layout_alignParentTop="true" 
     android:paddingLeft="5dp" 
     android:paddingRight="5dp"> 

     <!-- Song Title --> 
     <TextView 
      android:id="@+id/videoTitle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:textColor="#04b3d2" 
      android:textSize="16sp" 
      android:paddingLeft="10dp" 
      android:textStyle="bold" 
      android:text="@string/song_def_title" 
      android:layout_marginTop="10dp"/> 

     <!-- Full Screen button --> 
     <ImageButton 
      android:id="@+id/btnFullScreen" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:src="@drawable/ic_action_refresh" 
      android:background="@null" /> 

     <!-- Playlist button --> 
     <ImageButton 
      android:id="@+id/btnPlaylist" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:src="@drawable/btn_playlist" 
      android:background="@null"/> 
    </LinearLayout> 

    <VideoView 
     android:id="@+id/surface_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/player_header_bg" > 

    </VideoView> 

</RelativeLayout> 

어떤 풍경에 방향 변경, 나는 같은 XML 파일 이름을 가지고 있지만 레이아웃 토지 폴더에서이 XML이있을 때 다음과 같은 XML

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <VideoView 
     android:id="@+id/surface_view" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" > 
    </VideoView> 

</RelativeLayout> 

어떤 문제가없는 방향 변경과 함께하지만, 가로 모드에서 동작 표시 줄과 알림 표시 줄을 타고 싶었습니다. 세로 모드에서 나오게하십시오.

수동으로 onConfigurationChanged 메서드를 재정의하려했지만 잘 작동하지 않습니다.

@Override 
    public void onConfigurationChanged(Configuration newConfig) { 
     super.onConfigurationChanged(newConfig); 

     if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { 
      ActionBar actionBar = getActionBar(); 
      actionBar.hide(); 

      WindowManager.LayoutParams attrs = getWindow().getAttributes(); 
      attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; 
      getWindow().setAttributes(attrs); 

      // setContentView(R.layout.player_video_fs); 
     } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { 
      ActionBar actionBar = getActionBar(); 
      actionBar.show(); 

      WindowManager.LayoutParams attrs = getWindow().getAttributes(); 
      attrs.flags |= WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN; 
      getWindow().setAttributes(attrs); 

      // setContentView(R.layout.player_video); 
     } 
    } 

나는 위의 작업을 수행하는 경우에 나는 가로로 변경하는 경우, 그것은 액션 바 및 notificationbar을 제거하지만 난 세로로 다시 변경할 때 액션 바는 약간 이상한 얻을. 그것이 어떻게 끊어 지는지보십시오. 대신 비디오를 재생 계속의 blackscreen 것 같은 액션 바는

actiobar

그리고 가로로 변경, 그것은 보인다.

다른 방법을 시도했지만 해결할 수 없습니다. 어떤 생각?

+0

나는 문제가 무엇인지 잘 모르겠지만, 새 프로젝트를 만들 때 작업 표시 줄이 아웃 저런 애하고와 "전체 화면"활동의 종류 활동 템플릿에 있습니다 풍경 작업 표시 줄은 다음과 같습니다 이클립스에서 체크 아웃. – urSus

답변

1

나는 또한이 문제가있어서이 질문에 비틀 거렸다. 나는 그것이 날짜가 있지만 여기에 오는 미래의 개발자를 돕는다는 것을 알고 있습니다. 플래그를 창을 속성 설정 | (=) 당신은 단순히 숨어의 getWindow().clearFlags(flag) or getWindow().addFlags(flag) 기능

그래서 내 수정 된 버전 호출 할 수 있습니다

주변 검색 후 내가 대신 화합물 또는 연산자를 사용하는 경우 간단한 해결책이 Praveen에서 제공 발견

if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { 
    getActionBar().hide(); 
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { 
    getActionBar().show(); 
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 
} 
+0

안드로이드 이상 롤리팝 버전의 경우 getSupportActionBar.hide() 및 getSupportActionBar.show()를 사용하십시오. – tmac12

관련 문제