繁体   English   中英

按钮覆盖Scrollview

[英]Buttons are covering Scrollview

查看此代码

<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,但没有运气。 请帮助。

通过在ScrollView中添加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用ScrollView填充了屏幕,并将按钮置于屏幕下方。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM