How to set margin for Vertical Scrollbar from the right edge in ListView?
If you care about your design and want to apply the style globally use this.
res/values/styles.xml
<item name="android:scrollbarThumbVertical">@drawable/scrollbar</item>
res/drawable/scrollbar.xml
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:right="4dp"> <!-- Your Margin --> <shape> <solid android:color="@color/red500" /> <!-- Your Color --> <corners android:radius="2dp" /> <!-- Your Radius --> <size android:width="4dp" /> <!-- Your Width --> </shape> </item></layer-list>
All the other answers were created by developers, not designers like myself.
Result
Refer to documentation on android:scrollbarStyle
attribute of View
. The style you probably want to use is insideOverlay
(in conjunction with android:paddingRight
).
Something like
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal" android:paddingRight="50dip"> <ListView android:id="@+id/scrollable_table" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbarStyle="insideOverlay"> . . .