视频控件默认位于设备底部
我正在开发一个应用程序,并且我将视频均匀地堆叠在图像之上。您可以在所附照片中看到这一点。为什么视频播放器控件默认位于设备底部,如图所示?如果可能的话,我想将它们移到视频上方。我的此屏幕布局是:
<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/mobile_vforum_bg"
>
<VideoView
android:id="@+id/vidPlayer"
android:layout_width="320dip"
android:layout_height="240dip">
</VideoView>
<WebView
android:id="@+id/slideHolder"
android:layout_width="320dip"
android:layout_height="240dip"
android:layout_gravity="bottom">
</WebView>
<ListView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/slideList"
android:background="#000000">
</ListView>
</FrameLayout>
有人知道我是否可以将视频控件移动到视频顶部吗?
I am working on an app and I have video stacked evenly on top of an image. You can see that in the attached photo. Why do the video player controls default to the bottom of the device like in the photo? I want to move them over top just the video if possible. My layout for this screen is:
<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/mobile_vforum_bg"
>
<VideoView
android:id="@+id/vidPlayer"
android:layout_width="320dip"
android:layout_height="240dip">
</VideoView>
<WebView
android:id="@+id/slideHolder"
android:layout_width="320dip"
android:layout_height="240dip"
android:layout_gravity="bottom">
</WebView>
<ListView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/slideList"
android:background="#000000">
</ListView>
</FrameLayout>
anyone know if I can move the video controls on top of the video?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您要做的是确保为控件设置锚点视图,并确保锚点视图不会占据整个屏幕。例如,这是一个示例布局(不完整,但明白了要点):
然后,在设置媒体控制器时的代码中,您将执行以下操作:
关键是内部线性布局具有高度的换行内容,因此它不占据整个屏幕。这最终将在视频下方显示控件。如果您想做一些更时髦的事情,例如将控件放在视频本身之上(然后出现/消失),那么我相信您必须创建自己的控件并将它们与视频视图一起放置。
What you want to do is make sure to set an anchor view for the controls and to make sure the anchor view doesn't take up the whole screen. For example, here's a sample layout (incomplete, but gets the point across):
Then, in your code when you set the media controller, you would do the following:
The key is that the inner linear layout has wrap content for the height so it doesn't take up the entire screen. This will end up showing the controls right under the video. If you want to do something even more funky like have the controls on top of the video itself (and have then appear/disappear), then I believe you would have to create your own controls and lay them out with the video view.
这可能与您使用 FrameLayout 并且显示屏上没有足够的空间来显示所有内容有关。您是否需要为您的尺寸使用精确的像素规格?如果可能的话,您应该始终避免这些,因为在 Android 中您永远不知道您的应用程序将在多大的屏幕上运行。
It probably has to do with the fact you're using a FrameLayout and there's not enough room on the display to display everything. Is there a reason you need to use exact pixel specifications for your size? You should always avoid those if possible because in android you never know what size of screen your app is going to be running on.