2013-02-20 115 views
0

检查出这个代码按钮覆盖滚动型

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<ScrollView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:fadeScrollbars="true" 
    android:scrollbarStyle="insideInset" > 

    <TextView 
     android:id="@+id/txt" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:autoLink="all" 
     android:paddingLeft="3dp" 
     android:paddingRight="3dp" 
     android:textIsSelectable="true" /> 
</ScrollView> 

<Button 
    android:id="@+id/nextbtn" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:onClick="nextButton" 
    android:text="@string/next" /> 

<Button 
    android:id="@+id/backbtn" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:onClick="prevButton" 
    android:text="@string/back" /> 

我得到的结果是,尽管滚动视图和文本显示,在底部的按钮,左边和左下角都在顶部文字/滚动视图。我曾尝试使用linearlayout,但没有运气。请帮助。

+0

给你的滚动视图一个ID,并尝试添加到您的按钮:'android:layout_below =“@ + id/scrollViewId”' – 2013-02-20 20:33:21

+0

尝试贾斯汀V的回答@mister_dani – Shoshi 2013-02-20 20:48:03

回答

1

尝试通过你的滚动型增加android:layout_above="@+id/nextbtn"如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:fadeScrollbars="true" 
     android:scrollbarStyle="insideInset" 
     android:layout_above="@+id/nextbtn" > 

     <TextView 
      android:id="@+id/txt" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:autoLink="all" 
      android:paddingLeft="3dp" 
      android:paddingRight="3dp" 
      android:textIsSelectable="true" /> 
    </ScrollView> 

    <Button 
     android:id="@id/nextbtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:onClick="nextButton" 
     android:text="next" /> 

    <Button 
     android:id="@+id/backbtn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:onClick="prevButton" 
     android:text="back" /> 

</RelativeLayout> 

编辑:不幸的是,因为Android的填充屏幕上用滚动型和贾斯汀五答案不工作把你下面的按钮,出来的屏幕。

+0

谢谢,亚历克斯河你如何处理按钮:“id/backbtn”too – 2013-02-21 07:28:03

+0

非常感谢alex,完美工作 – 2013-02-21 08:25:46

+0

不客气:) – 2013-02-21 08:31:15