2013-04-24 8 views
10

का पहलू अनुपात मैं वीडियोव्यू भरने के उद्देश्य से वीडियो खींचने का प्रयास करता हूं। लक्ष्य यह देखने के लिए है कि डिवाइस में पहली तस्वीर की तरह दिखता है (जैसे यह लेआउट पूर्वावलोकन में दिखता है)।वीडियो व्यू भरने के लिए खिंचाव, वीडियो व्यू

इस सवालों के जवाब में से अधिकांश this link को देखें।

मैं इस कोशिश की, लेकिन मैं अभी भी वीडियो दृश्य नहीं भरा था।

यह मेरा लेआउट कोड:

enter image description here

हालांकि, डिवाइस पर परिणाम अलग है::

enter image description here

<?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> 

यहाँ आप मेरी घोषित लेआउट के एक पूर्वावलोकन है

+0

आपका लेआउट कोड अपनी जरूरत को पूरा करने के ठीक है आवश्यकता नहीं है। लेकिन ध्यान रखें कि 'वीडियो व्यू' उसमें चल रहे वीडियो के संबंध में घट जाएगा/खिंचाव करेगा। –

+0

ठीक है, इसलिए मुझे मीडिया रिकॉर्डर के पहलू अनुपात को बदलने की जरूरत है mmediaRecorder.setVideoSize (640, 480) जोड़ने के लिए; मैं कोशिश करता हूं और यह काम करता है ... ??? – idan

+0

जांच इस जवाब http://stackoverflow.com/a/38971707/1153703 –

उत्तर

25

अपने बाहरी लेआउट को रिश्तेदार लेआउट बनाने का प्रयास करें और उसमें वीडियो व्यू डालें।

कुछ की तरह:

<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

सही .... धन्यवाद .... – idan

+0

महान .. यह काम करता है .. – Neela

+0

यह workssss fuc..ing !! यह इस चीज़ को हासिल करने का सबसे आसान तरीका है। मैं इसे हासिल करने के लिए बहुत समय बर्बाद कर रहा हूं। बहुत बहुत धन्यवाद!!!!!! – KinGPinG

संबंधित मुद्दे