布局:从顶部开始的底栏+滚动视图

布局:从顶部开始的底栏+滚动视图

问题描述:

我找不到解决方案。我设法解决了scrollview与我的按钮+ textview在底部不重叠的问题,但我仍然无法设置从屏幕顶部开始而不是从按钮上方开始的滚动视图。布局:从顶部开始的底栏+滚动视图

请注意,即使底部的linearlayout(按钮+ textview)不完全是我想要的。我找不到让所有东西都能正确定位的方法。

Eclipse并没有帮助,因为xml的文本视图不断变化在我的鼠标下,使它非常恼人。我不得不打开一个外部编辑器来编辑它。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/RelativeLayout1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:gravity="center|top" > 
<LinearLayout 
    android:id="@+id/LinearLayout2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" > 
    <TextView 
     android:id="@+id/text_phrase" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Large Text" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 
    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right" 
     android:text="@string/play" /> 
</LinearLayout> 
<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/LinearLayout2" 
    android:layout_alignParentLeft="true" 
    android:layout_marginBottom="18dp" > 




    <LinearLayout 
     android:id="@+id/layout_player_checkboxes" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="top" 
     android:orientation="vertical" > 

     <CheckBox 
      android:id="@+id/checkBox1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="CheckBox" /> 
    </LinearLayout> 

</ScrollView> 

+0

你能告诉我你是如何布置的,或者图像会很好 – Triode 2012-03-23 14:17:54

+0

我看到的新的*不允许我轻松编辑:(我希望你能看到这个链接:http://我。 imgur.com/RaOLE.png这是我想要的,但是通过上面的代码,我可以将三个“Heading3”锚定到下面的线性布局,而不是像图片中显示的那样固定在顶部。 – maugch 2012-03-23 14:39:59

+0

好吧,您需要一些像这样的事情,标题的数量被限制为三或者它将是动态的 – Triode 2012-03-23 14:42:31

如果添加android:layout_alignParentTop="true"android:layout_weight="1"您滚动型,同时留下你有什么已经休息,就应该开始在顶部,填写下面的屏幕直到它linearlayout2。 (如果你决定切换到列表视图rajesh.adhi建议同样适用)

哦,你似乎也错过了</RelativeLayout>那里。

+0

权重仅适用于linearlayout。它被相对布局忽略.AlignParentTop应该做的伎俩, – njzk2 2012-03-23 15:44:46

+0

Doh。我以为他有scrollview包裹在一个线性布局,在这种情况下,它会产生影响。感谢您指出我的错误。 – Barak 2012-03-23 16:00:28

+0

我想我试图将scrollview包装在linearlayout中,但结果是scrollview将按钮和底部的文本重叠。 – maugch 2012-03-24 13:40:25