Android上的布局问题带的FrameLayout和滚动型 [英] Layout issue on Android with FrameLayout and ScrollView

查看:1696
本文介绍了Android上的布局问题带的FrameLayout和滚动型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在屏幕中2个区域分割,向左一个的ImageView 和向右一个 ScrolView 。我加入的ImageView 和滚动型编程的内容,因此布局的xml文件看起来是这样的:

I'm trying to split the screen in 2 areas, to the left an ImageView and to the right a ScrolView. I'm adding the ImageView and the content of the ScrollView programatically, so the xml file of the layout looks like this:

<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>

我是什么做错了吗?因为我发现了滚动型来的权利,但的ImageView 置于中心(相对于屏幕)屏幕左侧。图像的分辨率超过了屏幕的分辨率,所以我得到黑SP

What am I doing wrong? because I'm getting the ScrollView to the right, but the ImageView centered (relative to the screen) placed on the left of the screen. The resolution of the image exceeds the screen's resolution so I get black sp

推荐答案

我想你应该利用的LinearLayout 重量参数来解决这个问题。

I think you should make use of the LinearLayout and the weight parameter to solve this problem.

我已经编辑您的片段,给你的,你应该如何使用它的想法。

I have edited your snippet to give you an idea of how you should use it.

<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>

我希望它能帮助。

I hope it helps..

这篇关于Android上的布局问题带的FrameLayout和滚动型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆