|
| 1 | +# MaterialScrollBar |
| 2 | +An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices. |
| 3 | + |
| 4 | +<a href="https://play.google.com/store/apps/details?id=com.turingtechnologies.materialscrollbardemo"> |
| 5 | + <img alt="Android app on Google Play" src="https://developer.android.com/images/brand/en_app_rgb_wo_45.png" /> |
| 6 | +</a> |
| 7 | + |
| 8 | +Preview |
| 9 | +------- |
| 10 | + |
| 11 | +[Video](https://youtu.be/CmcPsJYuzME) |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +How to add |
| 17 | +-------- |
| 18 | + |
| 19 | +```gradle |
| 20 | +maven { |
| 21 | + url "https://jitpack.io" |
| 22 | +} |
| 23 | +``` |
| 24 | + |
| 25 | +```gradle |
| 26 | +dependencies { |
| 27 | + compile 'com.github.krimin-killr21:MaterialScrollBar:2.+' |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +How to use - ScrollBar |
| 32 | +-------- |
| 33 | +It is very important that the scroller be aligned to the right side of the screen in order to present correctly. You can manipulate the handle and bar colours through the xml or programatically. The recomended width for the view is 20dp to allow for a reasonable area for dragging on the side of the screen. |
| 34 | + |
| 35 | +```xml |
| 36 | +<com.turingtechnologies.materialscrollbar.MaterialScrollBar |
| 37 | + android:id="@+id/material_scroller" |
| 38 | + android:layout_width="20dp" |
| 39 | + android:layout_height="match_parent" |
| 40 | + app:handleColour="{{colour here}}" (optional) |
| 41 | + app:barColour="{{colour here}}" (optional) |
| 42 | + android:layout_alignParentRight="true" |
| 43 | + android:layout_alignTop="@+id/recycler_view" /> |
| 44 | +``` |
| 45 | + |
| 46 | +Lastly, it also imperative that you give the materialScrollBar whatever recyclerView to which you wish to attach it. If you fail to do this, the library will spam error messages to the log until you fix it. |
| 47 | + |
| 48 | +```java |
| 49 | +materialScrollBar.setRecyclerView(recyclerView); |
| 50 | +``` |
| 51 | + |
| 52 | +How to use - Section Indicator |
| 53 | +-------- |
| 54 | +Every step here is important, so make sure you've done them all. |
| 55 | + |
| 56 | +1- Add it to the xml. |
| 57 | + |
| 58 | +```xml |
| 59 | +<com.turingtechnologies.materialscrollbar.SectionIndicator |
| 60 | + android:layout_width="100dp" |
| 61 | + android:id="@+id/sectionIndicator" |
| 62 | + android:layout_alignRight="[Id of scrollBar]" |
| 63 | + android:layout_alignTop="[Id of scrollBar]" |
| 64 | + android:layout_height="match_parent"/> |
| 65 | +``` |
| 66 | +2- Link the scrollBar and the section indicator programatically. |
| 67 | + |
| 68 | +```java |
| 69 | + scrollBar.setSectionIndicator((SectionIndicator) findViewById(R.id.sectionIndicator)); |
| 70 | +``` |
| 71 | + |
| 72 | +3- Make the adapter for your recyclerView implement INameableAdapter and fill in the getCharacterForElement method for your adapter. |
| 73 | + |
| 74 | +License |
| 75 | +-------- |
| 76 | + |
| 77 | + Copyright 2015 Wynne Plaga. |
| 78 | + |
| 79 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 80 | + you may not use this file except in compliance with the License. |
| 81 | + You may obtain a copy of the License at |
| 82 | + |
| 83 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 84 | + |
| 85 | + Unless required by applicable law or agreed to in writing, software |
| 86 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 87 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 88 | + See the License for the specific language governing permissions and |
| 89 | + limitations under the License. |
0 commit comments