How To Set Margin For Vertical Scrollbar From The Right Edge In Listview?
For Android Platform: I need to put margin on right side of the vertical scrollbar in listview (it is customized). Please see the attached image. Default scrollbar sticks to the ex
Solution 1:
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-listxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:right="4dp"><!-- Your Margin --><shape><solidandroid:color="@color/red500" /><!-- Your Color --><cornersandroid:radius="2dp" /><!-- Your Radius --><sizeandroid:width="4dp" /><!-- Your Width --></shape></item></layer-list>
All the other answers were created by developers, not designers like myself.
Result
Solution 2:
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
<LinearLayoutandroid:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"android:gravity="center_horizontal"android:paddingRight="50dip"><ListViewandroid:id="@+id/scrollable_table"android:layout_width="fill_parent"android:layout_height="wrap_content"android:scrollbarStyle="insideOverlay">
.
.
.
Solution 3:
Try enabling fast scroll, it does the job most of the time:
<ListView
android:id="@+id/chapter_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fastScrollEnabled="true"/>
Post a Comment for "How To Set Margin For Vertical Scrollbar From The Right Edge In Listview?"