1

我正在尝试将屏幕分成 2 个区域,左侧是ImageViewa ,右侧是 a ScrolView。我正在以ImageView编程方式添加 ScrollView 的内容,因此布局的 xml 文件如下所示:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <FrameLayout
            android:id="@+id/scene_view"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="left"
            >
    </FrameLayout>
    <ScrollView
            android:layout_height="fill_parent"
            android:layout_width="@dimen/scrollmenu_width"
            android:layout_gravity="right"
            >
        <LinearLayout
                android:id="@+id/scrollmenu"
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:layout_width="fill_parent"
                >
        </LinearLayout>
    </ScrollView>
</FrameLayout>

我究竟做错了什么?因为我要ScrollView向右,但ImageView居中(相对于屏幕)位于屏幕左侧。图像的分辨率超过了屏幕的分辨率,所以我得到黑色 sp

4

1 回答 1

2

我认为你应该利用LinearLayoutandweight参数来解决这个问题。

我已经编辑了您的代码片段,让您了解应该如何使用它。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">

    <FrameLayout
        android:id="@+id/scene_view"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_gravity="left"
        android:layout_weight=1>
    </FrameLayout>
    <ScrollView
        android:layout_height="fill_parent"
        android:layout_width="0dp"
        android:layout_weight=1
        android:layout_gravity="right">
        <LinearLayout
            android:id="@+id/scrollmenu"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:layout_width="fill_parent">
        </LinearLayout>
    </ScrollView>
</FrameLayout>

我希望它有帮助..

于 2012-01-01T15:02:17.860 回答