Reputation: 111
I have an Android app which has a activity where custom data can be shown.
I need horizontal and vertical scrollbars
so that the data can be seen if the size is larger than the screen.
So i've tried to add a HorizontalScrollView
, which adds the horizontal scroll, but now the button is no longer glued to the bottom of the screen. What do i do?
<?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>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<Button
android:id="@+id/buttonAlarmOverview"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:background="@drawable/rounded_button"
android:onClick="onButtonClick"
android:text="@string/button_show_more" />
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
</android.support.constraint.ConstraintLayout>
Upvotes: 0
Views: 36
Reputation: 578
Hey try the following code :-
<?xml version="1.0" encoding="utf-8"?>
<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
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
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>
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
<LinearLayout
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<Button
android:id="@+id/buttonAlarmOverview"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:background="@drawable/rounded_button"
android:onClick="onButtonClick"
android:text="@string/button_show_more" />
</LinearLayout>
Upvotes: 1