11

I'm using a ScrollView and I want to set the ScrollBar size, but everything I tried failed. I tried with attribute android:scrollbarSize, with style, with the theme but nothing. The size of the scrollbar it's always the same. Any suggestions? Thanks

I tried with this:

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:layout_marginTop="10px"
    android:layout_marginBottom="15px"
    android:scrollbarSize="20px"
    android:scrollbarTrackVertical="@drawable/scrollbar_reflection"
    android:scrollbarThumbVertical="@drawable/scrollbar_state2">

but the width of the Scrollbar doesn't change.

So I created a style file like this:

<resources>
    <style name="ShowAllScrollBar1">
        <item name="android:scrollbarSize">20px</item>           
    </style>
</resources>

and then set style in AndroidManifest.

1
  • Could you show an example of what you tried? Commented Sep 17, 2010 at 17:11

3 Answers 3

5

Try implementing android:scrollbarThumbVertical and android:scrollbarSize="1dp" together, and your problem will be solved for ScrollView, RecyclerView.

Refer following code snippet

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:layout_marginTop="10px"
    android:layout_marginBottom="15px"
    android:scrollbars="vertical"
    android:scrollbarThumbVertical="@color/colorPrimaryDark"
    android:scrollbarSize="1dp">

For HorizontalScrollView:

<HorizontalScrollView
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:layout_marginTop="10px"
    android:layout_marginBottom="15px"
    android:scrollbars="horizontal"
    android:scrollbarThumbHorizontal="@color/colorPrimaryDark"
    android:scrollbarSize="1dp">
Sign up to request clarification or add additional context in comments.

3 Comments

I tried this solution but it doesn't work on my android 7.0 version <HorizontalScrollView android:id="@+id/hScrollTags" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbarThumbVertical="@color/colorPrimaryDark" android:scrollbarSize="1dp">
@SachinTanpure you're using HorizontalScrollView. So you should use android:scrollbarThumbHorizontal="@color/colorPrimaryDark". And your problem will be solved.
@SachinTanpure check my updated answer and your doubt will be solved.
3

I've actually been struggling with this as well. Unfortunately, it appears that the problem is actually in the Android sourcecode, and will not be fixed until the next Android release. After a bit of searching, I found this info here: http://code.google.com/p/android/issues/detail?id=14317.

1 Comment

Also, I've noticed that when you use a custom scrollbar drawable via the android:scrollbarThumbHorizontal style attribute, the system will just stretch it to fit the same dimensions as the original scrollbar that you are trying to enlarge. So that doesn't work either.
0

Have you tried to change the scrollbar drawable to some bigger one?

android:scrollbarThumbHorizontal

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.