2010-01-22 22 views
9

Có thể đặt chế độ xem bất kỳ trên VideoView không? (Ví dụ: đặt các nút điều khiển trên video, như trong vimeo). Tôi đang cố gắng làm điều đó bằng cách sử dụng FrameLayout, nhưng tôi đã không tìm thấy cách, và tôi vẫn không chắc chắn nếu những gì tôi đang cố gắng để làm một cái gì đó là chỉ đơn giản là không thể.Đặt bất kỳ Chế độ xem nào qua VideoView trong Android

Trả lời

2

Nó sẽ hoạt động tốt, mặc dù tôi sẽ sử dụng RelativeLayout. Bạn có thể thấy một tập hợp bố cục tương tự here, mặc dù cho một SurfaceView sử dụng MediaPlayer để phát lại video thay vì VideoView. Tuy nhiên, không có sự khác biệt.

6

Tôi làm điều này với FrameLayout. Những gì bạn cần làm là đảm bảo rằng các điều khiển bên dưới VideoView trong Trình chỉnh sửa bố cục.

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

    <VideoView 
     android:id="@+id/VideoView" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" /> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/ControlLayout" 
     android:layout_gravity="bottom|center_horizontal"> 

     <Button 
      android:text="@+id/Button01" 
      android:id="@+id/Button01" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
     <Button 
      android:text="@+id/Button02" 
      android:id="@+id/Button02" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
     <Button 
      android:text="@+id/Button03" 
      android:id="@+id/Button03" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
     <Button 
      android:text="@+id/Button04" 
      android:id="@+id/Button04" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 
</FrameLayout> 
+3

Và nếu tôi sử dụng 'setZOrderOnTop (true)' cho môi trường 'VideoView' bởi vì nó là một giải pháp theo [probelm này] (http://stackoverflow.com/questions/19650483/video-is-not -showing-on-videoview-nhưng-i-can-nghe-âm thanh của nó), làm thế nào tôi có thể đặt các quan điểm trên nó sau đó? – Eido95

+0

đúng, 'setZOrderOnTop' sẽ tạo VideoView trên mọi thứ, vì vậy cách giải quyết –

Các vấn đề liên quan