Android 如何在除平板电脑以外的所有设备上实现此布局

Android 如何在除平板电脑以外的所有设备上实现此布局,android,android-framelayout,Android,Android Framelayout,我现在不担心平板电脑,只担心安卓手机。我有一些现收现付的LG手机,我用它来开发。我有一个带有VideoView和WebView的框架布局 我的XML文件定义了特定像素处的宽度和高度,这对于在我的一台设备上进行测试非常有效。我在另一台屏幕更大的设备上试过,它们不像我的go手机那样填满窗口 我想知道如何在屏幕的上半部分填充我的视频,下半部分填充和图像。我尝试将layout\u width作为match\u parent,但不确定如何定义高度。这是我想要在所有设备上实现的布局 还有我的layout

我现在不担心平板电脑,只担心安卓手机。我有一些现收现付的LG手机,我用它来开发。我有一个带有
VideoView
WebView
的框架布局

我的XML文件定义了特定像素处的宽度和高度,这对于在我的一台设备上进行测试非常有效。我在另一台屏幕更大的设备上试过,它们不像我的go手机那样填满窗口

我想知道如何在屏幕的上半部分填充我的视频,下半部分填充和图像。我尝试将
layout\u width
作为
match\u 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>


显然我不能在这里使用像素量,那么我的选择是什么呢?谢谢,我希望我的问题足够清楚。

为什么要使用
框架布局?这适用于需要覆盖视图的情况。在这种情况下,一个简单的带有orientation=“vertical”的
线性布局就可以了

<LinearLayout 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="fill_parent"
        android:layout_height="fill_parent">
    </VideoView>
    <WebView 
        android:id="@+id/slideHolder"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
     </WebView>
</LinearLayout>


为什么要使用
框架布局
?这适用于需要覆盖视图的情况。在这种情况下,一个简单的带有orientation=“vertical”的
线性布局就可以了

<LinearLayout 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="fill_parent"
        android:layout_height="fill_parent">
    </VideoView>
    <WebView 
        android:id="@+id/slideHolder"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
     </WebView>
</LinearLayout>


使用垂直线性布局,并为两个视图指定
布局\u weight=“1”

<LinearLayout 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_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    </VideoView>
    <WebView 
        android:id="@+id/slideHolder"
        android:layout_weight="1"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
     </WebView>
</LinearLayout>


使用垂直线性布局,并为两个视图指定
布局\u weight=“1”

<LinearLayout 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_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    </VideoView>
    <WebView 
        android:id="@+id/slideHolder"
        android:layout_weight="1"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
     </WebView>
</LinearLayout>


我很确定我需要使用FrameLayout。我删除了位于VideoView和WebView顶部的列表视图。它通过菜单按钮打开。我删除了它,因为我认为它与问题无关,但显然我错了。这么说吧,我想我是在叠加观点。我想我找到了答案。我保持了我的布局不变,但我没有使用
320px
而是使用了
320dip
,这似乎解决了所有不同解决方案中的问题,而这些解决方案并非适用于所有手机。如果你需要FrameLayout做其他的事情,而不仅仅是把这两个项目放在FrameLayout的线性布局中。我很确定我需要使用FrameLayout。我删除了位于VideoView和WebView顶部的列表视图。它通过菜单按钮打开。我删除了它,因为我认为它与问题无关,但显然我错了。这么说吧,我想我是在叠加观点。我想我找到了答案。我保持了我的布局不变,但我没有使用
320px
而是使用了
320dip
,这似乎解决了所有不同解决方案中的问题,而这些解决方案并非适用于所有手机。如果您还需要FrameLayout来做其他事情,而不仅仅是将这两项放在FrameLayout中的线性布局中。