当按钮停留在底部时水平和垂直滚动

我有一个 Android 应用程序,它有一个可以显示自定义数据的活动。


我需要水平和垂直,scrollbars以便在尺寸大于屏幕时可以看到数据。


所以我尝试添加一个HorizontalScrollView,它添加了水平滚动,但现在按钮不再粘在屏幕底部。我该怎么办?


<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout 

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_behavior="@string/appbar_scrolling_view_behavior"

tools:context=".activities.UserModeAdvancedActivity"

tools:showIn="@layout/activity_user_mode_advanced">


<ScrollView

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:fillViewport="true">


    <HorizontalScrollView

        android:fillViewport="true"

        android:layout_width="match_parent"

        android:layout_height="match_parent">


    <LinearLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:orientation="vertical">


        <TableLayout

            android:id="@+id/tableLayout_user_mode_advanced"

            android:layout_width="match_parent"

            android:layout_height="0dp"

            android:layout_marginStart="24dp"

            android:layout_weight="1"

            android:padding="6dp"

            android:stretchColumns="*"

            app:layout_constraintStart_toStartOf="parent"

            tools:layout_editor_absoluteY="0dp">

        </TableLayout>

</android.support.constraint.ConstraintLayout>


PIPIONE
浏览 131回答 1
1回答

慕姐8265434

试试下面的代码:-&nbsp; &nbsp; <?xml version="1.0" encoding="utf-8"?>&nbsp; &nbsp; <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:weightSum="10"android:orientation="vertical"><ScrollView&nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; android:layout_height="0dp"&nbsp; &nbsp; android:layout_weight="9"&nbsp; &nbsp; android:fillViewport="true">&nbsp; &nbsp; <HorizontalScrollView&nbsp; &nbsp; &nbsp; &nbsp; android:fillViewport="true"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="match_parent">&nbsp; &nbsp; &nbsp; &nbsp; <LinearLayout&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:orientation="vertical">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <TableLayout&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/tableLayout_user_mode_advanced"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="0dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginStart="24dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_weight="1"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:padding="6dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:stretchColumns="*"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintStart_toStartOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tools:layout_editor_absoluteY="0dp">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </TableLayout>&nbsp; &nbsp; &nbsp; &nbsp; </LinearLayout>&nbsp; &nbsp; </HorizontalScrollView></ScrollView><LinearLayout&nbsp; &nbsp; android:layout_height="0dp"&nbsp; &nbsp; android:layout_weight="1"&nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; android:gravity="center_horizontal">&nbsp; &nbsp; <Button&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/buttonAlarmOverview"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="200dp"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:background="@drawable/rounded_button"&nbsp; &nbsp; &nbsp; &nbsp; android:onClick="onButtonClick"&nbsp; &nbsp; &nbsp; &nbsp; android:text="@string/button_show_more" /></LinearLayout>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java