2014-02-05 3 views
0

это мой XML-файл:изменения свойств макета на изменение конфигурации приводит к тому, вид искажаться

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:id="@+id/videoactivity" 
    > 

    <FrameLayout android:id="@+id/videoContainer" 
         android:layout_width="match_parent" android:layout_height="match_parent" 
         android:layout_weight="4" 
         android:background="#ffffff" 
         > 

       <com.schoolinsites.MediaPlayer.VideoView 
           android:id="@+id/videoView" android:layout_width="match_parent" 
           android:layout_height="wrap_content" android:layout_gravity="center"> 
       </com.schoolinsites.MediaPlayer.VideoView> 
        <ProgressBar 
         android:id="@+id/progressBar1" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:visibility="invisible" 
         /> 

       <com.schoolinsites.viewgroup.AdvertisementsView 
        android:layout_width="match_parent" 
         android:layout_height="60dp" 
         android:layout_gravity="bottom" 
         android:layout_marginLeft="20dp" 
         android:layout_marginRight="20dp" 
         android:id="@+id/advertisementcontrol" 
        ></com.schoolinsites.viewgroup.AdvertisementsView> 

       </FrameLayout> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/list_cardId" 
     android:layout_marginTop="2dp" 
     android:layout_marginLeft="12dp" 
     android:layout_marginRight="12dp" 
     android:background="@drawable/card_background" 
     android:layout_weight="2" 
     /> 

</LinearLayout> 

, когда я изменить ориентацию экрана, я меняюсь свойства макета, используя код, приведенный ниже, но после изменения ориентации видеоизображение искажается.

@Override 
     public void onConfigurationChanged(Configuration newConfig) { 

      super.onConfigurationChanged(newConfig); 
      if(IsFullscreen) 
      { 

      } 

      else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) 
      { 
       mVideo.pause(); 
       mVideo.setBackgroundColor(R.drawable.action_search); 
       LinearLayout layout = (LinearLayout)findViewById(R.id.videoactivity); 
       layout.setOrientation(LinearLayout.HORIZONTAL); 
       FrameLayout bottomFrameLayout = (FrameLayout)findViewById(R.id.videoContainer); 
       LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT,1); 
       lp.bottomMargin = 100; 
       bottomFrameLayout.setLayoutParams(lp); 
       mVideo.start(); 

      } 
      else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) 
      { 
       mVideo.pause(); 
       LinearLayout layout = (LinearLayout)findViewById(R.id.videoactivity); 
       layout.setOrientation(LinearLayout.VERTICAL); 
       FrameLayout bottomFrameLayout = (FrameLayout)findViewById(R.id.videoContainer); 
       LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT,4); 
       bottomFrameLayout.setLayoutParams(lp); 
       mVideo.start(); 
      } 

     } 

Как изменить ориентацию без искажения видеоизображения. может ли кто-нибудь помочь мне в решении проблемы.

ответ

0

i thing's this realy, если ваша работа над 3.0+ android, в AndroidMainfest, в вашей деятельности добавить, android:configChanges="screenSize"

 Смежные вопросы

  • Нет связанных вопросов^_^