Reposition scroll bar of ListView with padding

JPvdMerwe picture JPvdMerwe · Jul 6, 2011 · Viewed 20.2k times · Source

I have a ListView with padding to the right (and left).

Currently the list looks something like this:

-----------------  |
| ROW         | |  |
|-------------| |  |
| ROW         | |  |
|-------------|#|  |
| ROW         |#|  |
|-------------| |  |
| ROW         | |  |
-----------------  |

Where the right-most line is the edge of the screen, with the #s being the scrollbar and the white space to the right of it being the ListView's padding to the right.

What I is for the scroll bar to be to the right of the padding like this:

                    _
-----------------  | |
| ROW           |  | |
|---------------|  | |
| ROW           |  |#|
|---------------|  |#|
| ROW           |  |#|
|---------------|  | |
| ROW           |  | |  
-----------------  |_|

Is it possible to move the scrollbar like that or will I have to change the layouts for each row to have an invisible border of the right size?

Note currently each row has a separate background set by the adapter, since I'm making a floating window for my ListView and unfortunately one of my screens require me to do this in order to get it to look the way I want.

Answer

Haisea picture Haisea · Oct 17, 2011

Try this:

<ListView
    ...
    android:scrollbarStyle="outsideOverlay" />