library / org.akop.kotx.ext.view / android.view.View

Extensions for android.view.View

addGlobalLayoutListener

fun View.addGlobalLayoutListener(l: OnGlobalLayoutListener): Unit

animate

fun View.animate(animationResId: Int): Unit

Loads and begins animation with specified resource id.

fun View.animate(animationResId: Int, butFirst: Animation.(View) -> Unit = {}, andThen: Animation.(View) -> Unit = {}, onRepeat: Animation.(View) -> Unit = {}): Unit

Loads and begins animation with specified resource id, optionally executing a block specified by butFirst prior to animation, andThen following the animation, and onRepeat upon repeat.

fun View.animate(animation: Animation, butFirst: Animation.(View) -> Unit = {}, andThen: Animation.(View) -> Unit = {}, onRepeat: Animation.(View) -> Unit = {}): Unit

Begins animation, optionally executing a block specified by butFirst prior to animation, andThen following the animation, and onRepeat upon repeat.

collapse

fun View.collapse(): Unit

Sets receiver's visibility View.GONE.

collapseIf

fun View.collapseIf(value: Boolean): Unit

Sets receiver's visibility to View.GONE if value is true; sets it to View.VISIBLE otherwise. Opposite of expandIf; also see hideIf.

expand

fun View.expand(): Unit

Sets receiver's visibility View.VISIBLE.

expandIf

fun View.expandIf(value: Boolean = false): Unit

Sets receiver's visibility to View.VISIBLE if value is true; sets it to View.GONE otherwise. Opposite of collapseIf; also see showIf.

findParent

fun <T> View.findParent(): T?

Finds parent of the view of type T, not including the view itself.

hide

fun View.hide(): Unit

Sets receiver's visibility View.INVISIBLE.

hideIf

fun View.hideIf(value: Boolean): Unit

Sets receiver's visibility to View.INVISIBLE if value is true; sets it to View.VISIBLE otherwise. Opposite of showIf; also see collapseIf.

isCollapsed

val View.isCollapsed: Boolean

Returns true if receiver's View.getVisibility is View.GONE.

isExpanded

val View.isExpanded: Boolean

Returns true if receiver's View.getVisibility is View.VISIBLE.

isHidden

val View.isHidden: Boolean

Returns true if receiver's View.getVisibility is View.INVISIBLE.

isVisible

val View.isVisible: Boolean

Same as isExpanded.

removeGlobalLayoutListener

fun View.removeGlobalLayoutListener(l: OnGlobalLayoutListener): Unit

showIf

fun View.showIf(value: Boolean): Unit

Sets receiver's visibility to View.VISIBLE if value is true; sets it to View.INVISIBLE otherwise. Opposite of hideIf; also see expandIf.

showPopup

fun View.showPopup(menuResourceId: Int, onInit: PopupMenu.() -> Unit = {}, onClick: (MenuItem) -> Boolean): Unit

Displays a popup by inflating menu with specified menu resource id, calling onClick when an item is clicked, and optionally calling onInit with PopupMenu as receiver to initialize prior to display.