Skip to content

Commit

Permalink
- Added New function for to change color of text in Index scroll bar
Browse files Browse the repository at this point in the history
  • Loading branch information
myinnos_bob committed Feb 15, 2017
1 parent a40d742 commit c14fe02
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class IndexFastScrollRecyclerSection {

private float mIndexbarWidth;
private float mIndexbarMargin;
private float mPreviewPadding ;
private float mPreviewPadding;
private float mDensity;
private float mScaledDensity;
private int mListViewWidth;
Expand All @@ -41,6 +41,7 @@ public class IndexFastScrollRecyclerSection {
private int setIndexBarCornerRadius = IndexFastScrollRecyclerView.mIndexBarCornerRadius;
private float setIndexBarTransparentValue = IndexFastScrollRecyclerView.mIndexBarTransparentValue;
private String indexbarBackgroudColor = IndexFastScrollRecyclerView.mIndexbarBackgroudColor;
private String indexbarTextColor = IndexFastScrollRecyclerView.mIndexbarTextColor;

private int indexbarBackgroudAlpha = (int) (255 * setIndexBarTransparentValue);

Expand Down Expand Up @@ -93,7 +94,7 @@ public void draw(Canvas canvas) {
}

Paint indexPaint = new Paint();
indexPaint.setColor(indexPaintPaintColor);
indexPaint.setColor(Color.parseColor(indexbarTextColor));
indexPaint.setAntiAlias(true);
indexPaint.setTextSize(setIndexTextSize * mScaledDensity);

Expand Down Expand Up @@ -244,4 +245,11 @@ public void setIndexBarColor(String color) {
indexbarBackgroudColor = color;
}

/**
* @param color The color for the scroll track
*/
public void setIndexBarTextColor(String color) {
indexbarTextColor = color;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class IndexFastScrollRecyclerView extends RecyclerView {
public static int mIndexBarCornerRadius = 5;
public static float mIndexBarTransparentValue = (float) 0.6;
public static String mIndexbarBackgroudColor = "#000000";
public static String mIndexbarTextColor = "#FFFFFF";

public IndexFastScrollRecyclerView(Context context) {
super(context);
Expand Down Expand Up @@ -59,6 +60,10 @@ private void init(Context context, AttributeSet attrs) {
mIndexbarBackgroudColor = typedArray.getString(R.styleable.IndexFastScrollRecyclerView_setIndexBarColor);
}

if (typedArray.getString(R.styleable.IndexFastScrollRecyclerView_setIndexBarTextColor) != null) {
mIndexbarTextColor = typedArray.getString(R.styleable.IndexFastScrollRecyclerView_setIndexBarTextColor);
}

} finally {
typedArray.recycle();
}
Expand Down Expand Up @@ -170,4 +175,11 @@ public void setIndexBarColor(String color) {
mScroller.setIndexBarColor(color);
}

/**
* @param color The color for the text in scroll track
*/
public void setIndexBarTextColor(String color) {
mScroller.setIndexBarTextColor(color);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<attr name="setIndexBarCornerRadius" format="integer" />
<attr name="setIndexBarTransparentValue" format="float" />
<attr name="setIndexBarColor" format="string" />
<attr name="setIndexBarTextColor" format="string" />
</declare-styleable>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ protected void initialiseUI() {
mRecyclerView.setIndexbarMargin(0);
mRecyclerView.setIndexbarWidth(40);
mRecyclerView.setPreviewPadding(0);
mRecyclerView.setIndexBarTextColor("#FFFFFF");
}
}

0 comments on commit c14fe02

Please sign in to comment.