我正在使用VideoView展示本地的mp4,我也在使用MediaController。媒体控制栏不显示在我的视频剪辑下,而是显示在屏幕的中间。我使用setAnchorView将其附加到我的videoView上,但这没有任何影响。如何将媒体控制器定位为直接位于videoview下?
public class VideoDemo extends Activity {
private VideoView video;
private MediaController ctlr;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.main);
File clip=new File(Environment.getExternalStorageDirectory(),
"test.mp4");
if (clip.exists()) {
video=(VideoView)findViewById(R.id.video);
video.setVideoPath(clip.getAbsolutePath());
ctlr=new MediaController(this, false);
ctlr.setAnchorView(video);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
}
}
}我的布局是
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="400dp"
android:layout_height="400dp"
android:background="#fff"
>
<VideoView
android:id="@+id/video"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>发布于 2012-02-19 14:00:08
要让平板电脑应用程序以全屏显示媒体控制器,而不是居中显示,您需要在AndroidManifest.xml中添加一行uses-sdk行,并针对能够识别更高分辨率设备存在的sdk版本-否则,许多视图将限制为480x320
编辑:我之前发布过在添加uses-sdk时遇到一些问题,导致倒带/暂停/前进显示下面没有进度滑块,但事实证明,在适用于android的特定平板电脑上,软的主页/菜单/etc按钮栏只是覆盖了媒体控制器的下半部分。
发布于 2012-03-08 21:19:31
尝试:
ctrl.setPadding(x, y, z, w)发布于 2011-11-29 15:12:25
你能试试这个吗:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="400dp"
android:layout_height="400dp"
android:background="#fff"
android:orientation="vertical" >
<VideoView
android:id="@+id/video"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>然后使用as布局参数添加MediaController
希望这能有所帮助!
https://stackoverflow.com/questions/6511315
复制相似问题