如何在除平板电脑之外的所有设备上实现此布局
我现在不担心平板电脑,只担心安卓手机。我有一些即付即用的 LG 手机,我用它来进行开发。我有一个框架布局,其中有一个 VideoView
和一个 WebView
。
我的 XML 文件定义了特定像素的宽度和高度,并且在我的一台设备上进行测试时效果很好。我在另一台屏幕更大的设备上尝试过,它们不像我的手机那样填满窗口。
我想知道如何用视频填充屏幕的上半部分,用图像填充屏幕的下半部分。我尝试将 layout_width
作为 match_parent
,但后来我不确定如何定义高度。这是我想在所有设备上实现的布局。
和我的layout.xml
<?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="320px"
android:layout_height="240px">
</VideoView>
<WebView
android:id="@+id/slideHolder"
android:layout_width="320px"
android:layout_height="240px"
android:layout_gravity="bottom">
</WebView>
</FrameLayout>
显然我不能在这里使用像素量,那么我的选择是什么?谢谢你,我希望我的问题足够清楚。
I am not worried about tablets at the moment, just android phones. I have some pay as you go LG phone that I use to develop on. I have a frame layout with a VideoView
and a WebView
in it.
My XML file defined the width and height at specific pixels and that worked fine for testing on my one device. I tried it on another device which had a larger screen and they dont fill the window like on my go phone.
I was wondering how I can fill the top half of the screen with my video and the bottom half with and image. I tried layout_width
as match_parent
, but then I wasn't sure how to define the height. Here is the layout I want to achieve on all devices.
and my layout.xml
<?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="320px"
android:layout_height="240px">
</VideoView>
<WebView
android:id="@+id/slideHolder"
android:layout_width="320px"
android:layout_height="240px"
android:layout_gravity="bottom">
</WebView>
</FrameLayout>
Obviously I cant use a pixel amount here, so what are my options? Thank you and I hope my question was clear enough.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用垂直线性布局,并为两个视图指定
layout_weight="1"
。Use a vertical linearlayout, and specify
layout_weight="1"
for both views.为什么要使用
FrameLayout
?这适用于您想要覆盖视图的情况。在这种情况下,一个简单的带有orientation="vertical"的LinearLayout
应该可以解决问题。Why are you using a
FrameLayout
? That is meant for when you want to overlay views. In this case a simpleLinearLayout
with orientation="vertical" should do the trick.