scroll view in android code example

Example 1: how to not have the scroll bar drawn in scroll view android studii

android:scrollbars="none"

Example 2: scrollview android

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:stretchColumns="1">

        <!-- everything you already have -->

    </TableLayout>
</ScrollView>

Example 3: how to make textview scrollable inside scroll view

/**
 * If this [AppCompatTextView] is placed inside ScrollView then we allow it get scrolled inside
 * that ScrollView
 */
fun AppCompatTextView.makeScrollableInsideScrollView() {
    movementMethod = ScrollingMovementMethod()
    setOnTouchListener { v, event ->
        v.parent.requestDisallowInterceptTouchEvent(true)
        when (event.action and MotionEvent.ACTION_MASK) {
            MotionEvent.ACTION_UP -> {
                v.parent.requestDisallowInterceptTouchEvent(false)
                //It is required to call performClick() in onTouch event.
                performClick()
            }
        }
        false
    }

Example 4: scrollview scroll programmatically android

nestedScrollView.fullScroll(View.FOCUS_DOWN);
nestedScrollView.fullScroll(View.FOCUS_UP);

Example 5: scrollview scroll programmatically android

NestedScrollView.scrollTo(0, 0);