timusus / RecyclerView-FastScroll

A simple FastScroller for Android's RecyclerView
Other
1.39k stars 182 forks source link

Add possibility to change popup text size #28

Closed mathieupost closed 8 years ago

timusus commented 8 years ago

Thanks for your contribution. The text size should be passed in as a dimension resource rather than a pixel size. This allows the text size to adjust according to the user's text preferences, and doesn't restrict developers to providing a pixel size only.

app:fastScrollPopupTextSize="56sp" as opposed to app:fastScrollPopupTextSize="56"

The value would be retrieved with: typedArray.getDimensionPixelSize(R.styleable.FastScrollRecyclerView_fastScrollPopupTextSize, 56); as opposed to typedArray.getInt(R.styleable.FastScrollRecyclerView_fastScrollPopupTextSize, 56);

And set with: mTextPaint.setTextSize(TypedValue.COMPLEX_UNIT_PX, size)); as opposed to mTextPaint.setTextSize(Utils.toPixels(mRes, size));

Also, rather than hardcoding the background size to textSize + 32, we should probably just provide a setter for background size that defaults to textSize+32. That way, someone could potentially use a very small text size without resulting in a very small fast scroll popup.