Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scrollbar docs #227

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Why should you use this library?
| Prefetching upcoming items | ✅ | ❌ | ✅ |
| Reverse layout | ✅ | ❌ | ✅ |
| Testing library | ✅ | ❌ | ✅ |
| Scrollbars | ✅ | ❌ | ❌ |
| Drag and Drop | ✅ | ❌ | ❌ |
| Infinite layout with loop | ✅ | ❌ | ❌ |
| Smooth alignment changes | ✅ | ❌ | ❌ |
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Why should you use this library?
| Prefetching upcoming items | ✅ | ❌ | ✅ |
| Reverse layout | ✅ | ❌ | ✅ |
| Testing library | ✅ | ❌ | ✅ |
| Scrollbars | ✅ | ❌ | ❌ |
| Drag and Drop | ✅ | ❌ | ❌ |
| Infinite layout with loop | ✅ | ❌ | ❌ |
| Smooth alignment changes | ✅ | ❌ | ❌ |
Expand Down
64 changes: 64 additions & 0 deletions docs/recipes/scrollbars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Scrollbar Recipe

Scrollbars are composed of two parts:

1. Thumb: the main indicator for the current scroll position
2. Track: the background of the scrollbar


!!! note
Unfortunately, scrollbars can only be defined in XML. You can create a style for re-usability.

## Defining scrollbar appearance

Thumb example:

```xml linenums="1"
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<corners android:radius="4dp" />
<solid android:color="@color/white" />

</shape>
```

Track example:

```xml linenums="1"
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/black" />

</shape>

```

## `DpadRecyclerView` scrollbar configuration

To apply the above scrollbar appearance, place this in your `DpadRecyclerView` XML definition

```xml linenums="1" hl_lines="6-8"
<com.rubensousa.dpadrecyclerview.DpadRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarSize="6dp"
android:scrollbarThumbVertical="@drawable/scrollbar_thumb"
android:scrollbarTrackVertical="@drawable/scrollbar_track"
android:scrollbars="vertical" />
```

!!! note
Replace "Vertical" with "Horizontal" for horizontal scrollbars


By default, the scrollbar is only shown after scrolling and then disappears.
You can force it to always appear by using this attribute:

```xml linenums="1"
<com.rubensousa.dpadrecyclerview.DpadRecyclerView
android:scrollbarAlwaysDrawVerticalTrack="true" />
```

3 changes: 2 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ nav:
- 'Testing': testing.md
- 'XML attributes': xml.md
- 'Recipes':
- 'Alignment': recipes/alignment.md
- 'Layout': recipes/layout.md
- 'Spacing': recipes/spacing.md
- 'Alignment': recipes/alignment.md
- 'Focus': recipes/focus.md
- 'Scrolling': recipes/scrolling.md
- 'Scrollbars': recipes/scrollbars.md
- 'Drag and drop': recipes/dragdrop.md
- 'Changelog': changelog.md
- 'API': api/
Loading