Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ScrollView Scrollbar Size

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.

like image 663
carlovv Avatar asked Sep 17 '10 15:09

carlovv


People also ask

How do I stop Nestedscrollview scrolling?

setnestedscrollingenabled set it to false. try this one add property in recyclerview android:descendantFocusability="blocksDescendants" .

What is fillViewport?

android:fillViewport. Defines whether the scrollview should stretch its content to fill the viewport.


2 Answers

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">
like image 60
Pankaj Lilan Avatar answered Sep 22 '22 02:09

Pankaj Lilan


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.

like image 44
Levi Lindsey Avatar answered Sep 22 '22 02:09

Levi Lindsey