最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - ScrollView always visible from the start - Stack Overflow

programmeradmin3浏览0评论

I want to have my Scrollview always visible as you can see in the photo

The only problem is that I can manage to make the scrollbar background (this grey color) but not the white part that when you scroll it also scrolls. How can I make the white part also working?

My xml looks like this

    <?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android=";
    xmlns:app=";
    xmlns:tools=";
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    tools:context=".MainActivity">

    <!--I had to add this extra ScrollView otherwise the whole screen is not getting scrolled -->
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:layout_marginEnd="15dp"
        android:scrollbarThumbVertical="@color/white"
        android:scrollbarTrackVertical="@color/greyed_out"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbars="vertical"
        android:fadeScrollbars="false"
        android:scrollbarSize="30dp">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="30dp"
            android:layout_marginTop="30dp"
            android:layout_marginEnd="30dp">

         <other views...>

I have this line here android:scrollbarThumbVertical="@color/white" but still nothing happens.

I want to have my Scrollview always visible as you can see in the photo

The only problem is that I can manage to make the scrollbar background (this grey color) but not the white part that when you scroll it also scrolls. How can I make the white part also working?

My xml looks like this

    <?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android/apk/res/android"
    xmlns:app="http://schemas.android/apk/res-auto"
    xmlns:tools="http://schemas.android/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    tools:context=".MainActivity">

    <!--I had to add this extra ScrollView otherwise the whole screen is not getting scrolled -->
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:layout_marginEnd="15dp"
        android:scrollbarThumbVertical="@color/white"
        android:scrollbarTrackVertical="@color/greyed_out"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbars="vertical"
        android:fadeScrollbars="false"
        android:scrollbarSize="30dp">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="30dp"
            android:layout_marginTop="30dp"
            android:layout_marginEnd="30dp">

         <other views...>

I have this line here android:scrollbarThumbVertical="@color/white" but still nothing happens.

Share Improve this question asked Mar 18 at 12:55 AlexAlex 1,9366 gold badges25 silver badges41 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I fixed my issue by removing completely NestedScrollView and had my ScrollView as the top element.

发布评论

评论列表(0)

  1. 暂无评论