2013-04-24 24 views
10

'un en boy oranını doldurmak için streç Video görüntüsünü doldurmak amacıyla videoyu genişletmeye çalışıyorum. Hedef, cihazda ilk resme benzeyen görünüm oluşturmaktır (düzen önizlemesinde olduğu gibi).VideoView, VideoView

Bu soruların yanıtlarının çoğu this link'a başvurur.

Bunu denedim ancak video görüntüsünü hala doldurmadım.

Bu benim düzen kodu:

enter image description here

Ancak cihazda sonuç farklıdır:

enter image description here İşte

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/go_back" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:onClick="onclick" 
      android:text="Try again" /> 

     <Button 
      android:id="@+id/back_to_pick_song" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="Select another song" 
      android:onClick="onclick" /> 

     <Button 
      android:id="@+id/btn_continue" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:onClick="onclick" 
      android:text="Amazing, continue!" /> 
    </LinearLayout> 

    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
    <VideoView 
     android:id="@+id/videoView1" 
     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" 
     android:layout_gravity="center" /> 
    </FrameLayout> 
</LinearLayout> 

sen benim ilan düzeni önizlemesini var

+0

Yerleşim kodunuz, ihtiyacınızı karşılamak için uygun değildir. Ancak VideoView’un Video oynatma ile ilgili olarak küçüleceğini/gereceğini unutmayın. –

+0

tamam, bu yüzden mMediaRecorder.setVideoSize (640, 480) eklemek için medya kaydedici ortalamasının en boy oranını değiştirmem gerekiyor; Ben bunu deneyin ve çalışın ... ??? – idan

+0

bu cevabı kontrol edin http://stackoverflow.com/a/38971707/1153703 –

cevap

25

Dış düzeninizi göreceli bir düzen yapmaya çalışın ve VideoView'u bunun içine yerleştirin. gibi

şey:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/trim_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
      android:id="@+id/buttonContainer" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 

    <Button 
      android:id="@+id/go_back" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:onClick="onclick" 
      android:text="Try again" /> 

    <Button 
      android:id="@+id/back_to_pick_song" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:text="Select another song" 
      android:onClick="onclick" /> 

    <Button 
      android:id="@+id/btn_continue" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:layout_weight="1" 
      android:onClick="onclick" 
      android:text="Amazing, continue!" /> 
    </LinearLayout> 

    <VideoView 
    android:id="@+id/VideoView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@id/buttonContainer"/> 
</RelativeLayout> 
+0

Mükemmel .... Teşekkür ederim .... – idan

+0

Harika .. işte .. – Neela

+0

It fuc..ing workssss !! Bu şeyi başarmanın en kolay yolu budur. Bunu başarmaya çalışırken çok zaman harcıyorum. Çok teşekkürler!!!!!! – KinGPinG

5

başka solution buldum. Özel gereksinime gerek yoktur VideoView

İlgili konular