How I can make this scrollbar:
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
This perfect example guides you through the solution.
I've picked the main parts for fast use. if anyone needs more details, check the full article.
Vertical ScrollBar Track Drawable
Create a new file
res/drawable/scrollbar_vertical_track.xml
and copy paste the following content. This file defines shape for scrollbar track.Vertical ScrollBar Thumb Drawable
Create a new file
res/drawable/scrollbar_vertical_thumb.xml
and copy paste the following content. This file defines shape for scrollbar thumb.styles.xml
Create the following style and apply it to the ScrollView. Open
res/values/styles.xml
and edit to have the content as shown below.Applying the custom style to the
ScrollView
:We apply the style scrollbar_shape_style to the ScrollView which uses shape drawable.
To change the thumb image you can simply create the following style and apply it to your ScrollView:
where scroller_thumb is your custom image for the scroller thumb.
also note the following attributes:
Now, in order to put the thin line you want under the scroller, simply add an image view containing the line image, to the direct child of the ScrollView (RelativeLayout child as a direct child for the ScrollView will allow you to position the image on the right side of the view - so this is would have been my choice).
and that's it.
Setting android:scrollbarThumbVertical is not the best solution, it will stretch the thumb image according to the list size...
You'd better use android:fastScrollThumbDrawable
Here's an example:
Then on the styles.xml AppTheme you add
and on the res/drawable folder you create the file: scroller_style.xml with the content
where scroller is your thumb image and scroller_active is your active thumb image (optional)