Package-level declarations

Types

Link copied to clipboard
abstract class FlingGestureHandler @JvmOverloads constructor(activity: Activity, minDistance: Int = 100, velocityThreshold: Int = 100) : View.OnTouchListener
Link copied to clipboard

usage image.setOnTouchListener(object : OnSwipeTouchListener(this@MainActivity) {

Properties

Link copied to clipboard
val TextInputEditText.getString: String
Link copied to clipboard
Link copied to clipboard
var <T : View> BottomSheetBehavior<T>.isCollapsed: Boolean
Link copied to clipboard
var <T : View> BottomSheetBehavior<T>.isExpanded: Boolean
Link copied to clipboard
var <T : View> BottomSheetBehavior<T>.isExpandedHalf: Boolean
Link copied to clipboard
var <T : View> BottomSheetBehavior<T>.isHidden: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Default Snackbar duration. Set to Snackbar.LENGTH_LONG.

Link copied to clipboard
val Snackbar.textView: TextView?

Returns the Snackbar's text view by looking for android.support.design.R.id.snackbar_text in the view's layout.

Link copied to clipboard

Functions

Link copied to clipboard
fun Snackbar.action(@StringRes actionRes: Int, listener: (View) -> Unit)
fun Snackbar.action(@StringRes actionRes: Int, color: Int? = null, listener: (View) -> Unit)
fun Snackbar.action(action: String, color: Int? = null, listener: (View) -> Unit)
Link copied to clipboard
fun TextView.addDebounceChangeStateListener(delayInMillis: Long = 500, timeoutInMillis: Long = 0, listener: (Boolean) -> Unit)
Link copied to clipboard
fun TextView.addDebounceTextListener(debounceTimeInMillis: Long = 500, beforeChanged: (s: CharSequence) -> Unit? = null, afterChanged: (s: Editable) -> Unit? = null, onChanged: (s: CharSequence) -> Unit? = null)
Link copied to clipboard
inline fun TextView.addTextChangedListener(crossinline onBeforeTextChanged: (s: CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> }, crossinline onTextChanged: (s: CharSequence?, start: Int, before: Int, count: Int) -> Unit = { _, _, _, _ -> }, crossinline onAfterTextChanged: (s: Editable) -> Unit = { }): TextWatcher
Link copied to clipboard
fun TextView.addTextListener(beforeChanged: (s: CharSequence) -> Unit? = null, onChanged: (s: CharSequence) -> Unit? = null, afterChanged: (s: Editable) -> Unit? = null)
Link copied to clipboard
fun EditText.addTextWatcher(afterTextChanged: (text: Editable?) -> Unit = { _ -> }, beforeTextChanged: (text: CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> }, onTextChanged: (text: CharSequence?, start: Int, before: Int, count: Int) -> Unit = { _, _, _, _ -> }): TextWatcher

Accepts 3 text watcher methods with a default empty implementation.

Link copied to clipboard
fun EditText.afterTextChanged(afterTextChanged: (chars: Editable?) -> Unit = { _ -> })
Link copied to clipboard
Link copied to clipboard
fun TextView.backgroundColorSpan(str: String, range: IntRange, color: Int = Color.RED)
Link copied to clipboard
fun EditText.beforeTextChanged(beforeTextChanged: (chars: CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> })
Link copied to clipboard

Converts a Bitmap to a Drawable

Link copied to clipboard

Bold the TextView.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun TextInputLayout.clearError()
Link copied to clipboard
Link copied to clipboard
fun TextView.clickSpan(str: String, range: IntRange, color: Int = Color.RED, isUnderlineText: Boolean = false, clickListener: View.OnClickListener)
Link copied to clipboard
fun <T : View> BottomSheetBehavior<T>.collapse()
Link copied to clipboard
fun colorMenu(activity: Activity, menu: Menu, @ColorInt color: Int, alpha: Int = 0)

Sets a color filter on all menu icons, including the overflow button (if it exists)

Link copied to clipboard
fun colorMenuItem(menuItem: MenuItem, @ColorInt color: Int, alpha: Int = 0)

Sets a color filter on a MenuItem

Link copied to clipboard
fun TextView.colorSpan(str: String, range: IntRange, color: Int = Color.RED)
Link copied to clipboard
fun createSimpleRippleDrawable(@ColorInt foregroundColor: Int, @ColorInt backgroundColor: Int): RippleDrawable
Link copied to clipboard
fun createTintedDrawable(drawable: Drawable?, @ColorInt color: Int, mode: PorterDuff.Mode = PorterDuff.Mode.SRC_IN): Drawable?

Uses compatibility library to create a tinted a drawable. Supports all important versions of Android.

Link copied to clipboard
fun deleteAllWhenContainsStar(vararg editTexts: EditText)
Link copied to clipboard

DeleteLine for a TextView.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T : View> BottomSheetBehavior<T>.expand()
Link copied to clipboard
fun <T : View> BottomSheetBehavior<T>.expandHalf()
Link copied to clipboard
fun <T : EditText> T.filterInputByRegex(regex: Regex, onTextChanged: (String) -> Unit = {}): T

A keyboard handler for EditText that filters input by regex

Link copied to clipboard
fun <T : EditText> T.filterWhiteSpaces(onTextChanged: (String) -> Unit = {}): T

A keyboard handler for EditText that prohibits entering spaces, tabs, and so on

Link copied to clipboard
Link copied to clipboard
fun TextView.font(font: String, fontAbbreviation: String = ".ttf")

Set font for TextView.

Link copied to clipboard
fun RippleDrawable.forceAnimation(timeInMs: Long = 200, looper: Looper)
Link copied to clipboard
inline fun Menu.forEachIndexed(action: (index: Int, item: MenuItem) -> Unit)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

returns EditText text as URL

Link copied to clipboard
fun <T : View> BottomSheetBehavior<T>.hide()
Link copied to clipboard

Hides keyboard for this edit text with delay

Link copied to clipboard
fun Menu.indexOf(menuItem: MenuItem): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Measuring TextView height. Use this extension after view rendered

Link copied to clipboard

Measuring TextView width. Use this extension after view rendered

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun MenuItem?.onActionExpand(crossinline onExpand: () -> Unit = {}, crossinline onCollapse: () -> Unit = {})
Link copied to clipboard
inline fun CompoundButton.onChecked(crossinline block: () -> Unit)

Sets CompoundButton.OnCheckedChangeListener and calls specified function block if this button state changed to checked

Link copied to clipboard
inline fun CompoundButton.onCheckedChange(crossinline block: (isChecked: Boolean) -> Unit)

Sets CompoundButton.OnCheckedChangeListener and calls specified function block after checked state changed

Link copied to clipboard
inline fun MenuItem?.onCollapse(crossinline function: () -> Unit)
Link copied to clipboard
inline fun EditText.onDone(crossinline action: (text: String) -> Unit)

Both sets the EditText.setImeOptions to "Done" and listens for the IME action.

Link copied to clipboard
inline fun MenuItem?.onExpand(crossinline function: () -> Unit)
Link copied to clipboard
inline fun EditText.onFocused(crossinline block: () -> Unit)

Sets OnFocusChangeListener and calls specified function block if this view become focused

Link copied to clipboard
inline fun EditText.onImeAction(crossinline action: (text: String) -> Unit)

Listens for either the enter key to be pressed or the soft keyboard's editor action to activate.

Link copied to clipboard
inline fun EditText.onImeAction2(crossinline action: (view: View, text: String) -> Unit = { _, _ -> })
Link copied to clipboard
fun Spinner.onItemSelected(onNothingSelect: (parent: AdapterView<*>?) -> Unit = { _ -> }, onItemSelect: (parent: AdapterView<*>?, view: View?, position: Int, id: Long) -> Unit = { _, _, _, _ -> }): AdapterView.OnItemSelectedListener

Callback executed when a spinner item is selected

Link copied to clipboard
inline fun EditText.onKeyboardSubmit(crossinline block: EditText.() -> Unit)
Link copied to clipboard
inline fun EditText.onSend(crossinline action: (text: String) -> Unit)

Both sets the EditText.setImeOptions to "Send" and listens for the IME action.

Link copied to clipboard
fun EditText.onTextChanged(onTextChanged: (chars: CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> })
Link copied to clipboard
inline fun CompoundButton.onUnChecked(crossinline block: () -> Unit)

Sets CompoundButton.OnCheckedChangeListener and calls specified function block if this button state changed to unchecked

Link copied to clipboard
inline fun EditText.onUnFocused(crossinline block: () -> Unit)

Sets OnFocusChangeListener and calls specified function block if this view become unfocused

Link copied to clipboard

Sets EditText text from Clipboard

Link copied to clipboard
Link copied to clipboard
fun EditText.refocusWhenLost(delay: Long = 200)

Refocus an edit text when the focus is lost

Link copied to clipboard
fun Editable.replaceAll(newValue: String)

Extension method to replace all text inside an Editable with the specified newValue.

Link copied to clipboard

Extension method to replace all text inside an Editable with the specified newValue while ignoring any android.text.InputFilter set on the Editable.

Link copied to clipboard

Resets the cursor drawable to the default.

Link copied to clipboard
Link copied to clipboard
infix fun TextView.set(text: Spannable?)
infix fun TextView.set(@StringRes id: Int)
infix fun TextView.set(text: String?)
infix fun AppCompatTextView.set(text: String?)
Link copied to clipboard
Link copied to clipboard

Sets given content to TextView or hides it.

Link copied to clipboard
fun ImageView.setBase64(base64: String, flag: Int)
Link copied to clipboard
fun Drawable.setBoundsCentered(centerX: Float, centerY: Float)
fun Drawable.setBoundsCentered(centerX: Int, centerY: Int)

Sets the bounds of the drawable to be centered around the location centerX, centerY based on minimum size.

Link copied to clipboard
fun TextView.setColorOfSubstring(substring: String, color: Int)

Set different color for substring TextView.

Link copied to clipboard

Sets the cursor color of the edit text.

Link copied to clipboard

Set a drawable to the bottom of a TextView.

Link copied to clipboard

Set a drawable to the left of a TextView.

fun TextView.setDrawableLeft(drawable: Drawable?, width: Int = 0, height: Int = width)
Link copied to clipboard

Set a drawable to the right of a TextView.

Link copied to clipboard
fun TextView.setDrawables(left: Drawable? = null, top: Drawable? = null, right: Drawable? = null, bottom: Drawable? = null, width: Int = 0, height: Int = 0)
Link copied to clipboard
fun TextView.setDrawablesWithIntrinsicBounds(left: Drawable? = null, top: Drawable? = null, right: Drawable? = null, bottom: Drawable? = null)
Link copied to clipboard
fun TextView.setDrawableTop(drawable: Int)

Set a drawable to the top of a TextView.

Link copied to clipboard
fun TextView.setFont(typeface: Typeface?)
Link copied to clipboard
Link copied to clipboard
fun <T> Spinner.setItems(items: ArrayList<T>?, layoutResource: Int = android.R.layout.simple_spinner_dropdown_item, getTitle: (item: T) -> String = { a -> a.toString() }): SpinnerAdapter?

Sets an ArrayList of objects with an additional (but optional and which defaults to object.toString()) string conversion method for the same.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun MenuItem?.setQueryAndExpand(savedQuery: String?)
Link copied to clipboard
fun EditText.setReadOnly(readOnly: Boolean, inputType: Int = InputType.TYPE_NULL)
Link copied to clipboard
Link copied to clipboard
fun Drawable.setSize(width: Int, height: Int)
Link copied to clipboard
fun AppCompatTextView.setTextAndShowOrGone(context: Context, stringRes: Int, vararg params: Any? = emptyArray())
Link copied to clipboard
fun AppCompatTextView.setTextAndShowOrInvisible(context: Context, stringRes: Int, vararg params: Any? = emptyArray())
Link copied to clipboard
Link copied to clipboard

Set TextView from Html

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Setting new text to TextView with something like fade to alpha animation

Link copied to clipboard
fun TextView.setTextWithTransition(text: String, animDuration: Long)

Setting new text to TextView with something like width transition animation

Link copied to clipboard
fun TextInputEditText.setTheText(text: String)
Link copied to clipboard
fun ImageView.setTint(color: Int)

Change Imageview tint

fun ImageView.setTint(@ColorRes colorRes: Int, mode: PorterDuff.Mode = PorterDuff.Mode.SRC_OVER)
Link copied to clipboard

Usage setTitleColor(getCompatColor(R.color.colorPrimary))

Link copied to clipboard

Loads current device wallpaper to an Imageview

Link copied to clipboard

Shows keyboard for this edit text with delay

Link copied to clipboard
fun TextView.sizeSpan(str: String, range: IntRange, scale: Float = 1.5f)
Link copied to clipboard
fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG)
inline fun View.snack(@StringRes messageRes: Int, length: Int = Snackbar.LENGTH_LONG, f: Snackbar.() -> Unit)
inline fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG, f: Snackbar.() -> Unit)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun TextView.textColorAnim(from: Int, to: Int)
Link copied to clipboard

Set the text for an EditText if the EditText doesn't already have focus

Link copied to clipboard

Tint the drawable with a given color state list

Wrap the color into a state and tint the drawable

Link copied to clipboard
fun CharSequence.toBackgroundColorSpan(range: IntRange = IntRange(0, length), color: Int = Color.RED): SpannableString

Change the background color of the text specified in a paragraph of text

Link copied to clipboard
fun CharSequence.toBoldItalicSpan(range: IntRange = IntRange(0, length)): SpannableString

Change the text to bold italic

Link copied to clipboard
fun CharSequence.toBoldSpan(range: IntRange = IntRange(0, length)): SpannableString

Change the text to bold

Link copied to clipboard
fun CharSequence.toClickSpan(range: IntRange = IntRange(0, length), color: Int = Color.RED, isUnderlineText: Boolean = false, clickListener: View.OnClickListener): SpannableString

Add color and click event to the text of the specified range in the text

Link copied to clipboard
fun CharSequence.toColorSpan(range: IntRange = IntRange(0, length), color: Int = Color.RED): SpannableString

Change the foreground color of the text specified in a paragraph of text

Link copied to clipboard

Converts this Bitmap to a Drawable

Link copied to clipboard
fun CharSequence.toItalicSpan(range: IntRange = IntRange(0, length)): SpannableString

Change the text to italic

Link copied to clipboard
fun CharSequence.toNormalSpan(range: IntRange = IntRange(0, length)): SpannableString

Change the text to normal text

Link copied to clipboard
fun CharSequence.toSizeSpan(range: IntRange = IntRange(0, length), scale: Float = 1.5f): SpannableString

Change the size of the text in the specified range of text

Link copied to clipboard
fun CharSequence.toStrikeThroughSpan(range: IntRange = IntRange(0, length)): SpannableString

Add a strike through to the text of the specified range in the text

Link copied to clipboard
fun CharSequence.toStyleSpan(style: Int, range: IntRange = IntRange(0, length)): SpannableString

Set the span to a styled one from Typeface

Link copied to clipboard

Removes the bolding of a text view

Link copied to clipboard

UnderLine the TextView.

Link copied to clipboard
fun EditText.unfocusIfEmpty(delay: Long = 200)

Refocus an edit text when the focus is lost

Link copied to clipboard

Refocus an edit text when the focus is lost

Link copied to clipboard
fun EditText.updateCursorLocation(index: Int = text.length)
Link copied to clipboard
Link copied to clipboard
fun Snackbar.withTextColor(color: Int): Snackbar