0

我现在不担心平板电脑,只担心安卓手机。我有一些随用随付的 LG 手机,用于开发。我有一个带有 aVideoView和 a的框架布局WebView

我的 XML 文件定义了特定像素的宽度和高度,并且可以很好地在我的一台设备上进行测试。我在另一台具有更大屏幕的设备上进行了尝试,但它们并没有像我的 Go 手机那样填满窗口。

我想知道如何用视频填充屏幕的上半部分,用图像填充下半部分。我试过layout_widthas match_parent,但后来我不确定如何定义高度。这是我想在所有设备上实现的布局。

ss

和我的 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>

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

4

2 回答 2

2

使用垂直线性布局,并layout_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>
于 2011-05-19T22:11:44.660 回答
1

你为什么用一个FrameLayout?这适用于您想要覆盖视图时。在这种情况下,一个简单LinearLayout的方向=“垂直”应该可以解决问题。

<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>
于 2011-05-19T22:06:36.710 回答