2012-01-01 77 views
1

我想分割屏幕的2个区域,左边的ImageView和右边的ScrolView。我加入了ImageView和滚动型编程的内容,因此布局的XML文件看起来像这样:Android与FrameLayout和ScrollView的布局问题

<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

回答

2

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

我编辑过你的代码片段,让你知道你应该如何使用它。

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

我希望它有助于..

+1

啊啊啊,我知道这是可能的,只是我是新来的Android,并没有过我的脑海在这种情况下。谢谢你,解决方案的工作,虽然这不是你写'LinearLayout'的重量参数的方式 – Romeo 2012-01-01 15:11:33

+0

对不起,我很高兴能够提供帮助。 – 2012-01-01 15:14:58

+0

已经接受:)这是我正在寻找的解决方案 – Romeo 2012-01-01 15:16:01