KTX 拡張機能のリスト

androidx.activity

依存関係

Groovy

dependencies {
    implementation "androidx.activity:activity-ktx:1.9.0"
}

Kotlin

dependencies {
    implementation("androidx.activity:activity-ktx:1.9.0")
}

拡張関数

OnBackPressedDispatcher の場合
OnBackPressedCallback OnBackPressedDispatcher.addCallback(owner: LifecycleOwner? = null, enabled: Boolean = true, onBackPressed: OnBackPressedCallback.() -> Unit)

OnBackPressedCallback.handleOnBackPressedonBackPressed を呼び出す新しい OnBackPressedCallback を作成して追加します。

ComponentActivity の場合
Lazy<VM> ComponentActivity.viewModels(noinline factoryProducer: () -> ViewModelProvider.Factory = null)

ComponentActivity の ViewModel にアクセスする Lazy デリゲートを返します。factoryProducer が指定されている場合は、それによって返される ViewModelProvider.Factory が、初めて ViewModel を作成するために使用されます。

androidx.benchmark

依存関係

Groovy

dependencies {
    implementation "androidx.benchmark:benchmark-junit4:1.2.4"
}

Kotlin

dependencies {
    implementation("androidx.benchmark:benchmark-junit4:1.2.4")
}

トップレベル関数

Unit beginTraceSection(sectionName: String)

Unit endTraceSection()

androidx.benchmark.junit4

依存関係

Groovy

dependencies {
    implementation "androidx.benchmark:benchmark-junit4:1.2.4"
}

Kotlin

dependencies {
    implementation("androidx.benchmark:benchmark-junit4:1.2.4")
}

拡張関数

BenchmarkRule の場合
Unit BenchmarkRule.measureRepeated(crossinline block: BenchmarkRule.Scope.() -> Unit)

コードのブロックをベンチマークします。

androidx.collection

依存関係

Groovy

dependencies {
    implementation "androidx.collection:collection-ktx:1.4.0"
}

Kotlin

dependencies {
    implementation("androidx.collection:collection-ktx:1.4.0")
}

拡張関数

LongSparseArray の場合
operator Boolean LongSparseArray<T>.contains(key: Long)

コレクションに key が含まれている場合、true を返します。

Unit LongSparseArray<T>.forEach(action: (key: Long, value: T) -> Unit)

個々の Key-Value エントリに対して、指定された action を実行します。

T LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T)

key に対応する値を返します。値が存在しない場合は、defaultValue を返します。

T LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T)

key に対応する値を返します。値が存在しない場合は、defaultValue からの値を返します。

Boolean LongSparseArray<T>.isNotEmpty()

コレクションに要素が含まれている場合、true を返します。

LongIterator LongSparseArray<T>.keyIterator()

コレクションのキーのイテレータを返します。

operator LongSparseArray<T> LongSparseArray<T>.plus(other: LongSparseArray<T>)

other のエントリを追加または置換して、新しいコレクションを作成します。

Boolean LongSparseArray<T>.remove(key: Long, value: T)

keyvalue にマッピングされている場合にのみ、キーのエントリを削除します。

operator Unit LongSparseArray<T>.set(key: Long, value: T)

コレクションに値を格納するためのインデックス演算子を使用できるようにします。

Iterator<T> LongSparseArray<T>.valueIterator()

コレクションの値のイテレータを返します。

SparseArrayCompat の場合
operator Boolean SparseArrayCompat<T>.contains(key: Int)

コレクションに key が含まれている場合、true を返します。

Unit SparseArrayCompat<T>.forEach(action: (key: Int, value: T) -> Unit)

個々の Key-Value エントリに対して、指定された action を実行します。

T SparseArrayCompat<T>.getOrDefault(key: Int, defaultValue: T)

key に対応する値を返します。値が存在しない場合は、defaultValue を返します。

T SparseArrayCompat<T>.getOrElse(key: Int, defaultValue: () -> T)

key に対応する値を返します。値が存在しない場合は、defaultValue からの値を返します。

Boolean SparseArrayCompat<T>.isNotEmpty()

コレクションに要素が含まれている場合、true を返します。

IntIterator SparseArrayCompat<T>.keyIterator()

コレクションのキーのイテレータを返します。

operator SparseArrayCompat<T> SparseArrayCompat<T>.plus(other: SparseArrayCompat<T>)

other のエントリを追加または置換して、新しいコレクションを作成します。

Boolean SparseArrayCompat<T>.remove(key: Int, value: T)

keyvalue にマッピングされている場合にのみ、キーのエントリを削除します。

operator Unit SparseArrayCompat<T>.set(key: Int, value: T)

コレクションに値を格納するためのインデックス演算子を使用できるようにします。

Iterator<T> SparseArrayCompat<T>.valueIterator()

コレクションの値のイテレータを返します。

拡張プロパティ

LongSparseArray の場合
Int LongSparseArray<T>.size()

コレクションに含まれる Key-Value ペアの数を返します。

SparseArrayCompat の場合
Int SparseArrayCompat<T>.size()

コレクションに含まれる Key-Value ペアの数を返します。

トップレベル関数

ArrayMap<K, V> arrayMapOf()

空の新しい ArrayMap を返します。

ArrayMap<K, V> arrayMapOf(vararg pairs: Pair<K, V>)

指定された内容を持つ新しい ArrayMap を返します。Key-Value ペア(最初の要素がキーで 2 番目の要素が値)のリストとして指定します。

ArraySet<T> arraySetOf()

空の新しい ArraySet を返します。

ArraySet<T> arraySetOf(vararg values: T)

指定された内容を持つ新しい ArraySet を返します。

LruCache<K, V> lruCache(maxSize: Int, crossinline sizeOf: (key: K, value: V) -> Int = { _, _ -> 1 }, crossinline create: (key: K) -> V? = { null as V? }, crossinline onEntryRemoved: (evicted: Boolean, key: K, oldValue: V, newValue: V?) -> Unit = { _, _, _, _ -> })

指定されたパラメータで LruCache を作成します。

androidx.core.animation

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.animation.Animator の場合
AnimatorListener Animator.addListener(crossinline onEnd: (animator: Animator) -> Unit = {}, crossinline onStart: (animator: Animator) -> Unit = {}, crossinline onCancel: (animator: Animator) -> Unit = {}, crossinline onRepeat: (animator: Animator) -> Unit = {})

指定されたアクションを使用して、この Animator にリスナーを追加します。

AnimatorPauseListener Animator.addPauseListener(crossinline onResume: (animator: Animator) -> Unit = {}, crossinline onPause: (animator: Animator) -> Unit = {})

指定されたアクションを使用して、この Animator に一時停止および再開のリスナーを追加します。

AnimatorListener Animator.doOnCancel(crossinline action: (animator: Animator) -> Unit)

アニメーションがキャンセルされたときに起動するアクションを追加します。

AnimatorListener Animator.doOnEnd(crossinline action: (animator: Animator) -> Unit)

アニメーションが終了したときに起動するアクションを追加します。

AnimatorPauseListener Animator.doOnPause(crossinline action: (animator: Animator) -> Unit)

アニメーションが一時停止されたときに起動するアクションを追加します。

AnimatorListener Animator.doOnRepeat(crossinline action: (animator: Animator) -> Unit)

アニメーションが繰り返されたときに起動するアクションを追加します。

AnimatorPauseListener Animator.doOnResume(crossinline action: (animator: Animator) -> Unit)

アニメーションが一時停止後に再開されたときに起動するアクションを追加します。

AnimatorListener Animator.doOnStart(crossinline action: (animator: Animator) -> Unit)

アニメーションが開始したときに起動するアクションを追加します。

androidx.core.content

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.content.Context の場合
T? Context.getSystemService()

クラス別のシステムレベルのサービスへのハンドルを返します。

Unit Context.withStyledAttributes(set: AttributeSet? = null, attrs: IntArray, @AttrRes defStyleAttr: Int = 0, @StyleRes defStyleRes: Int = 0, block: TypedArray.() -> Unit)

TypedArray レシーバーで block を実行します。

Unit Context.withStyledAttributes(@StyleRes resourceId: Int, attrs: IntArray, block: TypedArray.() -> Unit)

TypedArray レシーバーで block を実行します。

android.content.SharedPreferences の場合
Unit SharedPreferences.edit(commit: Boolean = false, action: Editor.() -> Unit)

変更を保持するための apply または commit の呼び出しを含むこの優先設定インスタンスを編集できるようにします。

トップレベル関数

ContentValues contentValuesOf(vararg pairs: Pair<String, Any?>)

指定された Key-Value ペアを要素とする新しい ContentValues を返します。

androidx.core.content.res

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.content.res.TypedArray の場合
Boolean TypedArray.getBooleanOrThrow(@StyleableRes index: Int)

index の属性のブール値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Int TypedArray.getColorOrThrow(@StyleableRes index: Int)

index の属性のカラー値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

ColorStateList TypedArray.getColorStateListOrThrow(@StyleableRes index: Int)

index の属性のカラー状態リスト値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Float TypedArray.getDimensionOrThrow(@StyleableRes index: Int)

index の属性のディメンション値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Int TypedArray.getDimensionPixelOffsetOrThrow(@StyleableRes index: Int)

index の属性のディメンション ピクセル オフセット値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Int TypedArray.getDimensionPixelSizeOrThrow(@StyleableRes index: Int)

index の属性のディメンション ピクセルサイズ値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Drawable TypedArray.getDrawableOrThrow(@StyleableRes index: Int)

index の属性のドローアブル値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Float TypedArray.getFloatOrThrow(@StyleableRes index: Int)

index の属性の浮動小数点数値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Typeface TypedArray.getFontOrThrow(@StyleableRes index: Int)

index の属性のフォント値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Int TypedArray.getIntOrThrow(@StyleableRes index: Int)

index の属性の整数値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Int TypedArray.getIntegerOrThrow(@StyleableRes index: Int)

index の属性の整数値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Int TypedArray.getResourceIdOrThrow(@StyleableRes index: Int)

index の属性のリソース識別子を取得します。定義されていない場合は、IllegalArgumentException をスローします。

String TypedArray.getStringOrThrow(@StyleableRes index: Int)

index の属性の文字列値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

Array<CharSequence> TypedArray.getTextArrayOrThrow(@StyleableRes index: Int)

index の属性のテキスト配列値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

CharSequence TypedArray.getTextOrThrow(@StyleableRes index: Int)

index の属性のテキスト値を取得します。定義されていない場合は、IllegalArgumentException をスローします。

R TypedArray.use(block: (TypedArray) -> R)

指定された block 関数をこの TypedArray で実行し、それをリサイクルします。

androidx.core.database

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.database.Cursor の場合
ByteArray? Cursor.getBlobOrNull(index: Int)

リクエストされた列の値を null 許容型のバイト配列として返します。

Double? Cursor.getDoubleOrNull(index: Int)

リクエストされた列の値を null 許容型の倍精度浮動小数点数として返します。

Float? Cursor.getFloatOrNull(index: Int)

リクエストされた列の値を null 許容型の浮動小数点数として返します。

Int? Cursor.getIntOrNull(index: Int)

リクエストされた列の値を null 許容型の整数として返します。

Long? Cursor.getLongOrNull(index: Int)

リクエストされた列の値を null 許容型の長整数として返します。

Short? Cursor.getShortOrNull(index: Int)

リクエストされた列の値を null 許容型の短整数として返します。

String? Cursor.getStringOrNull(index: Int)

リクエストされた列の値を null 許容型の文字列として返します。

androidx.core.database.sqlite

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.database.sqlite.SQLiteDatabase の場合
T SQLiteDatabase.transaction(exclusive: Boolean = true, body: SQLiteDatabase.() -> T)

トランザクション内で body を実行し、例外を発生させずに完了した場合は成功としてマークします。

androidx.core.graphics

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.graphics.Bitmap の場合
Bitmap Bitmap.applyCanvas(block: Canvas.() -> Unit)

このビットマップに描画する新しい Canvas を作成し、指定された block を新規作成されたキャンバスで実行します。

operator Boolean Bitmap.contains(p: Point)

指定された点がビットマップの内部にある場合、true を返します。

operator Boolean Bitmap.contains(p: PointF)

指定された点がビットマップの内部にある場合、true を返します。

operator Int Bitmap.get(x: Int, y: Int)

指定された位置にあるピクセルの値を返します。

Bitmap Bitmap.scale(width: Int, height: Int, filter: Boolean = true)

可能であれば、このビットマップからスケーリングされた新しいビットマップを作成します。

operator Unit Bitmap.set(x: Int, y: Int, color: Int)

指定されたカラー整数を、指定された (x, y) 座標でビットマップ(可変であると仮定します)に書き込みます。

android.graphics.Canvas の場合
Unit Canvas.withClip(clipRect: Rect, block: Canvas.() -> Unit)

Canvas.save/Canvas.clipRect および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withClip(clipRect: RectF, block: Canvas.() -> Unit)

Canvas.save/Canvas.clipRect および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withClip(left: Int, top: Int, right: Int, bottom: Int, block: Canvas.() -> Unit)

Canvas.save/Canvas.clipRect および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withClip(left: Float, top: Float, right: Float, bottom: Float, block: Canvas.() -> Unit)

Canvas.save/Canvas.clipRect および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withClip(clipPath: Path, block: Canvas.() -> Unit)

Canvas.save/Canvas.clipPath および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withMatrix(matrix: Matrix = Matrix(), block: Canvas.() -> Unit)

Canvas.save/Canvas.concat および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withRotation(degrees: Float = 0.0f, pivotX: Float = 0.0f, pivotY: Float = 0.0f, block: Canvas.() -> Unit)

Canvas.save/Canvas.rotate および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withSave(block: Canvas.() -> Unit)

Canvas.save および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withScale(x: Float = 1.0f, y: Float = 1.0f, pivotX: Float = 0.0f, pivotY: Float = 0.0f, block: Canvas.() -> Unit)

Canvas.save/Canvas.scale および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withSkew(x: Float = 0.0f, y: Float = 0.0f, block: Canvas.() -> Unit)

Canvas.save/Canvas.skew および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

Unit Canvas.withTranslation(x: Float = 0.0f, y: Float = 0.0f, block: Canvas.() -> Unit)

Canvas.save/Canvas.translate および Canvas.restoreToCount の呼び出しで、指定された block をラップします。

android.graphics.Color の場合
operator Float Color.component1()

カラーの最初の要素を返します。

operator Float Color.component2()

カラーの 2 番目の要素を返します。

operator Float Color.component3()

カラーの 3 番目の要素を返します。

operator Float Color.component4()

カラーの 4 番目の要素を返します。

infix Color! Color.convertTo(colorSpace: Named)

カラー レシーバーを指定された色空間のカラーに変換します。

infix Color! Color.convertTo(colorSpace: ColorSpace)

カラー レシーバーを指定された色空間のカラーに変換します。

operator Color Color.plus(c: Color)

2 つの半透明のカラーを合成します。

android.graphics.ImageDecoder.Source の場合
Bitmap Source.decodeBitmap(crossinline action: ImageDecoder.(info: ImageInfo, source: Source) -> Unit)

ソースからビットマップを作成します。

Drawable Source.decodeDrawable(crossinline action: ImageDecoder.(info: ImageInfo, source: Source) -> Unit)

ソースからドローアブルを作成します。

android.graphics.Matrix の場合
operator Matrix Matrix.times(m: Matrix)

この Matrix に別の行列を乗算し、結果を新しい行列として返します。

FloatArray Matrix.values()

この Matrix の 9 個の値を新しい浮動小数点数配列として返します。

android.graphics.Paint の場合
Boolean Paint.setBlendMode(blendModeCompat: BlendModeCompat?)

Paint の BlendMode を下位互換で構成できる便利なメソッド。

android.graphics.Path の場合
infix Path Path.and(p: Path)

2 つのパスの交差を新しい Path として返します。

Iterable<PathSegment> Path.flatten(error: Float = 0.5f)

Path を一連の線分でフラット化(近似)します。

operator Path Path.minus(p: Path)

2 つのパスの差を新しい Path として返します。

infix Path Path.or(p: Path)

2 つのパスの和を新しい Path として返します。

operator Path Path.plus(p: Path)

2 つのパスの和を新しい Path として返します。

infix Path Path.xor(p: Path)

2 つのパスの和から交差を除いた部分を新しい Path として返します。

android.graphics.Picture の場合
Picture Picture.record(width: Int, height: Int, block: Canvas.() -> Unit)

この Picture にコマンドを記録する新しい Canvas を作成し、指定された block を新規作成されたキャンバスで実行して、この Picture を返します。

android.graphics.Point の場合
operator Int Point.component1()

この点の x 座標を返します。

operator Int Point.component2()

この点の y 座標を返します。

operator Point Point.minus(p: Point)

指定された点の否定によってこの点をオフセットし、結果を新しい点として返します。

operator Point Point.minus(xy: Int)

指定された数値を X 軸と Y 軸の両方でマイナスしてこの点をオフセットし、結果を新しい点として返します。

operator Point Point.plus(p: Point)

指定された点でこの点をオフセットし、結果を新しい点として返します。

operator Point Point.plus(xy: Int)

指定された数値を X 軸と Y 軸の両方でプラスしてこの点をオフセットし、結果を新しい点として返します。

PointF Point.toPointF()

この点の PointF 表現を返します。

operator Point Point.unaryMinus()

この点の否定を表す新しい点を返します。

android.graphics.PointF の場合
operator Float PointF.component1()

この点の x 座標を返します。

operator Float PointF.component2()

この点の y 座標を返します。

operator PointF PointF.minus(p: PointF)

指定された点の否定によってこの点をオフセットし、結果を新しい点として返します。

operator PointF PointF.minus(xy: Float)

指定された数値を X 軸と Y 軸の両方でマイナスしてこの点をオフセットし、結果を新しい点として返します。

operator PointF PointF.plus(p: PointF)

指定された点でこの点をオフセットし、結果を新しい点として返します。

operator PointF PointF.plus(xy: Float)

指定された数値を X 軸と Y 軸の両方でプラスしてこの点をオフセットし、結果を新しい点として返します。

Point PointF.toPoint()

この点の Point 表現を返します。

operator PointF PointF.unaryMinus()

この点の否定を表す新しい点を返します。

android.graphics.PorterDuff.Mode の場合
PorterDuffColorFilter Mode.toColorFilter(color: Int)

この PorterDuff.Mode をアルファ合成またはブレンドモードとして使用するとともに指定された color を使用する新しい PorterDuffColorFilter を作成します。

PorterDuffXfermode Mode.toXfermode()

この PorterDuff.Mode をアルファ合成またはブレンドモードとして使用する新しい PorterDuffXfermode を作成します。

android.graphics.Rect の場合
infix Rect Rect.and(r: Rect)

2 つの長方形の交差を新しい長方形として返します。

operator Int Rect.component1()

長方形の最初の要素である「left」を返します。

operator Int Rect.component2()

長方形の 2 番目の要素である「top」を返します。

operator Int Rect.component3()

長方形の 3 番目の要素である「right」を返します。

operator Int Rect.component4()

長方形の 4 番目の要素である「bottom」を返します。

operator Boolean Rect.contains(p: Point)

指定された点が長方形の内部にある場合、true を返します。

operator Region Rect.minus(r: Rect)

この長方形と指定された長方形の差を新しいリージョンとして返します。

operator Rect Rect.minus(xy: Int)

指定された数値を X 軸と Y 軸の両方でマイナスしてこの長方形をオフセットした領域を表す新しい長方形を返します。

operator Rect Rect.minus(xy: Point)

指定された点の否定によってこの長方形をオフセットした領域を表す新しい長方形を返します。

infix Rect Rect.or(r: Rect)

2 つの長方形の和を新しい長方形として返します。

operator Rect Rect.plus(r: Rect)

この長方形と指定された長方形の和を求め、結果を新しい長方形として返します。

operator Rect Rect.plus(xy: Int)

指定された数値を X 軸と Y 軸の両方でプラスしてこの長方形をオフセットした領域を表す新しい長方形を返します。

operator Rect Rect.plus(xy: Point)

指定された点でこの長方形をオフセットした領域を表す新しい長方形を返します。

operator Rect Rect.times(factor: Int)

この長方形の各要素を factor でスケーリングした領域を表す新しい長方形を返します。

RectF Rect.toRectF()

この長方形の RectF 表現を返します。

地域 Rect.toRegion()

この長方形の Region 表現を返します。

infix Region Rect.xor(r: Rect)

2 つの長方形の和から交差を除いた部分を新しいリージョンとして返します。

android.graphics.RectF の場合
infix RectF RectF.and(r: RectF)

2 つの長方形の交差を新しい長方形として返します。

operator Float RectF.component1()

長方形の最初の要素である「left」を返します。

operator Float RectF.component2()

長方形の 2 番目の要素である「top」を返します。

operator Float RectF.component3()

長方形の 3 番目の要素である「right」を返します。

operator Float RectF.component4()

長方形の 4 番目の要素である「bottom」を返します。

operator Boolean RectF.contains(p: PointF)

指定された点が長方形の内部にある場合、true を返します。

operator Region RectF.minus(r: RectF)

この長方形と指定された長方形の差を新しいリージョンとして返します。

operator RectF RectF.minus(xy: Float)

指定された数値を X 軸と Y 軸の両方でマイナスしてこの長方形をオフセットした領域を表す新しい長方形を返します。

operator RectF RectF.minus(xy: PointF)

指定された点の否定によってこの長方形をオフセットした領域を表す新しい長方形を返します。

infix RectF RectF.or(r: RectF)

2 つの長方形の和を新しい長方形として返します。

operator RectF RectF.plus(r: RectF)

この長方形と指定された長方形の和を求め、結果を新しい長方形として返します。

operator RectF RectF.plus(xy: Float)

指定された数値を X 軸と Y 軸の両方でプラスしてこの長方形をオフセットした領域を表す新しい長方形を返します。

operator RectF RectF.plus(xy: PointF)

指定された点でこの長方形をオフセットした領域を表す新しい長方形を返します。

operator RectF RectF.times(factor: Int)

この長方形の各要素を factor でスケーリングした領域を表す新しい長方形を返します。

operator RectF RectF.times(factor: Float)

この長方形の各要素を factor でスケーリングした領域を表す新しい長方形を返します。

Rect RectF.toRect()

この長方形の Rect 表現を返します。

地域 RectF.toRegion()

この長方形の Region 表現を返します。

RectF RectF.transform(m: Matrix)

指定された Matrix を使用して適切な位置でこの長方形を変換し、この長方形を返します。

infix Region RectF.xor(r: RectF)

2 つの長方形の和から交差を除いた部分を新しいリージョンとして返します。

android.graphics.Region の場合
infix Region Region.and(r: Rect)

このリージョンと指定された Rect の交差を新しいリージョンとして返します。

infix Region Region.and(r: Region)

このリージョンと指定されたリージョンの交差を新しいリージョンとして返します。

operator Boolean Region.contains(p: Point)

指定された Point がリージョンに含まれている場合、true を返します。

Unit Region.forEach(action: (rect: Rect) -> Unit)

指定されたアクションをこのリージョン内の各 rect で実行します。

operator Iterator<Rect> Region.iterator()

このリージョン内の rect の Iterator を返します。

operator Region Region.minus(r: Rect)

このリージョンと指定された Rect の差を新しいリージョンとして返します。

operator Region Region.minus(r: Region)

このリージョンと指定されたリージョンの差を新しいリージョンとして返します。

operator Region Region.not()

このリージョンの否定を新しいリージョンとして返します。

infix Region Region.or(r: Rect)

このリージョンと指定された Rect の和を新しいリージョンとして返します。

infix Region Region.or(r: Region)

このリージョンと指定されたリージョンの和を新しいリージョンとして返します。

operator Region Region.plus(r: Rect)

このリージョンと指定された Rect の和を新しいリージョンとして返します。

operator Region Region.plus(r: Region)

このリージョンと指定されたリージョンの和を新しいリージョンとして返します。

operator Region Region.unaryMinus()

このリージョンの否定を新しいリージョンとして返します。

infix Region Region.xor(r: Rect)

このリージョンと指定された Rect の和から交差を除いた部分を新しいリージョンとして返します。

infix Region Region.xor(r: Region)

このリージョンと指定されたリージョンの和から交差を除いた部分を新しいリージョンとして返します。

android.graphics.Shader の場合
Unit Shader.transform(block: Matrix.() -> Unit)

Shader.getLocalMatrixShader.setLocalMatrix の呼び出しで、指定された block をラップします。

kotlin.Int の場合
operator Int Int.component1()

カラー整数のアルファ要素を返します。

operator Int Int.component2()

カラー整数の赤要素を返します。

operator Int Int.component3()

カラー整数の緑要素を返します。

operator Int Int.component4()

カラー整数の青要素を返します。

infix Long Int.convertTo(colorSpace: Named)

カラー整数レシーバーを指定された色空間のカラー長整数に変換します。

infix Long Int.convertTo(colorSpace: ColorSpace)

カラー整数レシーバーを指定された色空間のカラー長整数に変換します。

Color Int.toColor()

カラー整数から新しい Color インスタンスを作成します。

Long Int.toColorLong()

指定された ARGB カラー整数sRGB 色空間の RGBA カラー長整数に変換します。

kotlin.Long の場合
operator Float Long.component1()

カラーの最初の要素を返します。

operator Float Long.component2()

カラーの 2 番目の要素を返します。

operator Float Long.component3()

カラーの 3 番目の要素を返します。

operator Float Long.component4()

カラーの 4 番目の要素を返します。

infix Long Long.convertTo(colorSpace: Named)

カラー長整数レシーバーを指定された色空間のカラー長整数に変換します。

infix Long Long.convertTo(colorSpace: ColorSpace)

カラー長整数レシーバーを指定された色空間のカラー長整数に変換します。

Color Long.toColor()

カラー長整数から新しい Color インスタンスを作成します。

Int Long.toColorInt()

指定されたカラー長整数を ARGB カラー整数に変換します。

kotlin.String の場合
Int String.toColorInt()

この String の対応する Int カラーを返します。

拡張プロパティ

kotlin.Int の場合
Int Int.alpha()

カラー整数のアルファ要素を返します。

Int Int.blue()

カラー整数の青要素を返します。

Int Int.green()

カラー整数の緑要素を返します。

Float Int.luminance()

sRGB エンコードを仮定して、カラー整数の相対輝度を返します。

Int Int.red()

カラー整数の赤要素を返します。

kotlin.Long の場合
Float Long.alpha()

カラー長整数のアルファ要素を返します。

Float Long.blue()

カラー長整数の青要素を返します。

ColorSpace Long.colorSpace()

指定されたカラー長整数でエンコードされた色空間を返します。

Float Long.green()

カラー長整数の緑要素を返します。

Boolean Long.isSrgb()

カラーが sRGB 色空間にあるかどうかを示します。

Boolean Long.isWideGamut()

カラーが広色域色空間にあるかどうかを示します。

Float Long.luminance()

カラーの相対輝度を返します。

Float Long.red()

カラー長整数の赤要素を返します。

トップレベル関数

Bitmap createBitmap(width: Int, height: Int, config: Config = Bitmap.Config.ARGB_8888)

指定された widthheight を持つ可変ビットマップを返します。

Bitmap createBitmap(width: Int, height: Int, config: Config = Bitmap.Config.ARGB_8888, hasAlpha: Boolean = true, colorSpace: ColorSpace = ColorSpace.get(ColorSpace.Named.SRGB))

指定された widthheight を持つ可変ビットマップを返します。

Matrix rotationMatrix(degrees: Float, px: Float = 0.0f, py: Float = 0.0f)

座標(px, py)にある回転軸を中心とする回転角度で定義される回転行列を作成します。

Matrix scaleMatrix(sx: Float = 1.0f, sy: Float = 1.0f)

x 軸と y 軸でそれぞれスケール係数 sx および sy を使用して、スケール行列を作成します。

Matrix translationMatrix(tx: Float = 0.0f, ty: Float = 0.0f)

x 軸と y 軸でそれぞれ平行移動量 tx および ty を使用して、平行移動行列を作成します。

androidx.core.graphics.drawable

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.graphics.Bitmap の場合
Icon Bitmap.toAdaptiveIcon()

このアダプティブ Bitmap から Icon を作成します。

BitmapDrawable Bitmap.toDrawable(resources: Resources)

この Bitmap から BitmapDrawable を作成します。

Icon Bitmap.toIcon()

この Bitmap から Icon を作成します。

android.graphics.Color の場合
ColorDrawable Color.toDrawable()

この Color から(Color.toArgb を使用して)ColorDrawable を作成します。

android.graphics.drawable.Drawable の場合
Bitmap Drawable.toBitmap(@Px width: Int = intrinsicWidth, @Px height: Int = intrinsicHeight, config: Config? = null)

この DrawableBitmap 表現を返します。

Unit Drawable.updateBounds(@Px left: Int = bounds.left, @Px top: Int = bounds.top, @Px right: Int = bounds.right, @Px bottom: Int = bounds.bottom)

このドローアブルの境界を更新します。

android.net.Uri の場合
Icon Uri.toIcon()

この Uri から Icon を作成します。

kotlin.ByteArray の場合
Icon ByteArray.toIcon()

この ByteArray から Icon を作成します。

kotlin.Int の場合
ColorDrawable Int.toDrawable()

このカラー値から ColorDrawable を作成します。

androidx.core.location

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.location.Location の場合
operator Double Location.component1()

この Location の緯度を返します。

operator Double Location.component2()

この Location の経度を返します。

androidx.core.net

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.net.Uri の場合
File Uri.toFile()

指定された Uri から File を作成します。

java.io.File の場合
Uri File.toUri()

指定されたファイルから Uri を作成します。

kotlin.String の場合
Uri String.toUri()

指定されたエンコード済みの URI 文字列から Uri を作成します。

androidx.core.os

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.os.Handler の場合
Runnable Handler.postAtTime(uptimeMillis: Long, token: Any? = null, crossinline action: () -> Unit)

Handler.postAtTime を、パラメータを並べ替えてアクションをかっこの外側に配置できるようにしたバージョン。

Runnable Handler.postDelayed(delayInMillis: Long, token: Any? = null, crossinline action: () -> Unit)

Handler.postDelayed を、パラメータを並べ替えてアクションをかっこの外側に配置できるようにしたバージョン。

トップレベル関数

Bundle bundleOf(vararg pairs: Pair<String, Any?>)

指定された Key-Value ペアを要素とする新しい Bundle を返します。

PersistableBundle persistableBundleOf(vararg pairs: Pair<String, Any?>)

指定された Key-Value ペアを要素とする新しい PersistableBundle を返します。

T trace(sectionName: String, block: () -> T)

Trace.beginSectionsectionName を指定)と Trace.endSection の呼び出しで、指定された block をラップします。

androidx.core.text

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.text.Spannable の場合
Unit Spannable.clearSpans()

このテキストからすべてのスパンを消去します。

operator Unit Spannable.set(start: Int, end: Int, span: Any)

テキストの start&hellip;end の範囲に span を追加します。

operator Unit Spannable.set(range: IntRange, span: Any)

テキストの rangespan を追加します。

android.text.SpannableStringBuilder の場合
SpannableStringBuilder SpannableStringBuilder.backgroundColor(color: Int, builderAction: SpannableStringBuilder.() -> Unit)

BackgroundColorSpanbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.bold(builderAction: SpannableStringBuilder.() -> Unit)

太字の StyleSpanbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.color(color: Int, builderAction: SpannableStringBuilder.() -> Unit)

ForegroundColorSpanbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.inSpans(vararg spans: Any, builderAction: SpannableStringBuilder.() -> Unit)

spansbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.inSpans(span: Any, builderAction: SpannableStringBuilder.() -> Unit)

spanbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.italic(builderAction: SpannableStringBuilder.() -> Unit)

斜体の StyleSpanbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.scale(proportion: Float, builderAction: SpannableStringBuilder.() -> Unit)

RelativeSizeSpanbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.strikeThrough(builderAction: SpannableStringBuilder.() -> Unit)

StrikethroughSpanbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.subscript(builderAction: SpannableStringBuilder.() -> Unit)

SubscriptSpanbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.superscript(builderAction: SpannableStringBuilder.() -> Unit)

SuperscriptSpanbuilderAction で付加テキストをラップします。

SpannableStringBuilder SpannableStringBuilder.underline(builderAction: SpannableStringBuilder.() -> Unit)

UnderlineSpanbuilderAction で付加テキストをラップします。

android.text.Panned の場合
Array<out T> Spanned.getSpans(start: Int = 0, end: Int = length)

T のインスタンスであるスパンをすべて取得します。

String Spanned.toHtml(option: Int = TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)

この Spanned のスパンから HTML の文字列を返します。

kotlin.CharSequence の場合
Boolean CharSequence.isDigitsOnly()

指定された CharSequence に数字のみが含まれるかどうかを返します。

Spannable CharSequence.toSpannable()

CharSequence から新しい Spannable を返します。すでに SpannableString のインスタンスである場合はソース自体を返します。

Spanned CharSequence.toSpanned()

CharSequence から新しい Spanned を返します。すでに SpannedString のインスタンスである場合はソース自体を返します。

Int CharSequence.trimmedLength()

String.trim などにより、指定された CharSequence の先頭と末尾からスペースと ASCII 制御文字を取り除いた場合の長さを返します。

kotlin.String の場合
String String.htmlEncode()

文字列を HTML にエンコードします。

Spanned String.parseAsHtml(flags: Int = FROM_HTML_MODE_LEGACY, imageGetter: ImageGetter? = null, tagHandler: TagHandler? = null)

この文字列を HTML として解析した結果から Spanned を返します。

拡張プロパティ

java.util.Locale の場合
Int Locale.layoutDirection()

指定されたロケールのレイアウト方向を返します。

トップレベル関数

SpannedString buildSpannedString(builderAction: SpannableStringBuilder.() -> Unit)

指定された builderAction を使用して新規作成の SpannableStringBuilder にデータを入力し、それを SpannedString に変換して、新しい文字列を構築します。

androidx.core.transition

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.transition.Transition の場合
TransitionListener Transition.addListener(crossinline onEnd: (transition: Transition) -> Unit = {}, crossinline onStart: (transition: Transition) -> Unit = {}, crossinline onCancel: (transition: Transition) -> Unit = {}, crossinline onResume: (transition: Transition) -> Unit = {}, crossinline onPause: (transition: Transition) -> Unit = {})

指定されたアクションを使用して、この Transition にリスナーを追加します。

TransitionListener Transition.doOnCancel(crossinline action: (transition: Transition) -> Unit)

このトランジションがキャンセルされたときに起動するアクションを追加します。

TransitionListener Transition.doOnEnd(crossinline action: (transition: Transition) -> Unit)

このトランジションが終了したときに起動するアクションを追加します。

TransitionListener Transition.doOnPause(crossinline action: (transition: Transition) -> Unit)

このトランジションが一時停止されたときに起動するアクションを追加します。

TransitionListener Transition.doOnResume(crossinline action: (transition: Transition) -> Unit)

このトランジションが一時停止後に再開されたときに起動するアクションを追加します。

TransitionListener Transition.doOnStart(crossinline action: (transition: Transition) -> Unit)

このトランジションが開始したときに起動するアクションを追加します。

androidx.core.util

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.util.AtomicFile の場合
ByteArray AtomicFile.readBytes()

このファイルのコンテンツ全体をバイト配列として取得します。

String AtomicFile.readText(charset: Charset = Charsets.UTF_8)

UTF-8 または指定された charset を使用して、このファイルのコンテンツ全体を文字列として取得します。

Unit AtomicFile.tryWrite(block: (out: FileOutputStream) -> Unit)

このファイルの block 内で書き込みオペレーションを実行します。

Unit AtomicFile.writeBytes(array: ByteArray)

このファイルのコンテンツをバイトの array として設定します。

Unit AtomicFile.writeText(text: String, charset: Charset = Charsets.UTF_8)

UTF-8 または指定された charset を使用して、このファイルのコンテンツを text としてエンコードするように設定します。

android.util.LongSparseArray の場合
operator Boolean LongSparseArray<T>.contains(key: Long)

コレクションに key が含まれている場合、true を返します。

Boolean LongSparseArray<T>.containsKey(key: Long)

コレクションに key が含まれている場合、true を返します。

Boolean LongSparseArray<T>.containsValue(value: T)

コレクションに value が含まれている場合、true を返します。

Unit LongSparseArray<T>.forEach(action: (key: Long, value: T) -> Unit)

個々の Key-Value エントリに対して、指定された action を実行します。

T LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T)

key に対応する値を返します。値が存在しない場合は、defaultValue を返します。

T LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T)

key に対応する値を返します。値が存在しない場合は、defaultValue からの値を返します。

Boolean LongSparseArray<T>.isEmpty()

コレクションに要素が含まれていない場合、true を返します。

Boolean LongSparseArray<T>.isNotEmpty()

コレクションに要素が含まれている場合、true を返します。

LongIterator LongSparseArray<T>.keyIterator()

コレクションのキーのイテレータを返します。

operator LongSparseArray<T> LongSparseArray<T>.plus(other: LongSparseArray<T>)

other のエントリを追加または置換して、新しいコレクションを作成します。

Unit LongSparseArray<T>.putAll(other: LongSparseArray<T>)

other のエントリを追加または置換して、このコレクションを更新します。

Boolean LongSparseArray<T>.remove(key: Long, value: T)

keyvalue にマッピングされている場合にのみ、キーのエントリを削除します。

operator Unit LongSparseArray<T>.set(key: Long, value: T)

コレクションに値を格納するためのインデックス演算子を使用できるようにします。

Iterator<T> LongSparseArray<T>.valueIterator()

コレクションの値のイテレータを返します。

android.util.Pair の場合
operator F Pair<F, S>.component1()

ペアの最初の要素を返します。

operator S Pair<F, S>.component2()

ペアの 2 番目の要素を返します。

Pair<F, S> Pair<F, S>.toKotlinPair()

この Pairkotlin.Pair として返します。

android.util.Range の場合
infix Range<T> Range<T>.and(other: Range<T>)

この範囲と other の交差を返します。

operator Range<T> Range<T>.plus(value: T)

この範囲と value を含む最小の範囲を返します。

operator Range<T> Range<T>.plus(other: Range<T>)

この範囲と other を含む最小の範囲を返します。

ClosedRange<T> Range<T>.toClosedRange()

この RangeClosedRange として返します。

android.util.Size の場合
operator Int Size.component1()

この Size の最初の要素である「width」を返します。

operator Int Size.component2()

この Size の 2 番目の要素である「height」を返します。

android.util.SizeF の場合
operator Float SizeF.component1()

この SizeF の最初の要素である「width」を返します。

operator Float SizeF.component2()

この SizeF の 2 番目の要素である「height」を返します。

android.util.SparseArray の場合
operator Boolean SparseArray<T>.contains(key: Int)

コレクションに key が含まれている場合、true を返します。

Boolean SparseArray<T>.containsKey(key: Int)

コレクションに key が含まれている場合、true を返します。

Boolean SparseArray<T>.containsValue(value: T)

コレクションに value が含まれている場合、true を返します。

Unit SparseArray<T>.forEach(action: (key: Int, value: T) -> Unit)

個々の Key-Value エントリに対して、指定された action を実行します。

T SparseArray<T>.getOrDefault(key: Int, defaultValue: T)

key に対応する値を返します。値が存在しない場合は、defaultValue を返します。

T SparseArray<T>.getOrElse(key: Int, defaultValue: () -> T)

key に対応する値を返します。値が存在しない場合は、defaultValue からの値を返します。

Boolean SparseArray<T>.isEmpty()

コレクションに要素が含まれていない場合、true を返します。

Boolean SparseArray<T>.isNotEmpty()

コレクションに要素が含まれている場合、true を返します。

IntIterator SparseArray<T>.keyIterator()

コレクションのキーのイテレータを返します。

operator SparseArray<T> SparseArray<T>.plus(other: SparseArray<T>)

other のエントリを追加または置換して、新しいコレクションを作成します。

Unit SparseArray<T>.putAll(other: SparseArray<T>)

other のエントリを追加または置換して、このコレクションを更新します。

Boolean SparseArray<T>.remove(key: Int, value: T)

keyvalue にマッピングされている場合にのみ、キーのエントリを削除します。

operator Unit SparseArray<T>.set(key: Int, value: T)

コレクションに値を格納するためのインデックス演算子を使用できるようにします。

Iterator<T> SparseArray<T>.valueIterator()

コレクションの値のイテレータを返します。

android.util.SparseBooleanArray の場合
operator Boolean SparseBooleanArray.contains(key: Int)

コレクションに key が含まれている場合、true を返します。

Boolean SparseBooleanArray.containsKey(key: Int)

コレクションに key が含まれている場合、true を返します。

Boolean SparseBooleanArray.containsValue(value: Boolean)

コレクションに value が含まれている場合、true を返します。

Unit SparseBooleanArray.forEach(action: (key: Int, value: Boolean) -> Unit)

個々の Key-Value エントリに対して、指定された action を実行します。

Boolean SparseBooleanArray.getOrDefault(key: Int, defaultValue: Boolean)

key に対応する値を返します。値が存在しない場合は、defaultValue を返します。

Boolean SparseBooleanArray.getOrElse(key: Int, defaultValue: () -> Boolean)

key に対応する値を返します。値が存在しない場合は、defaultValue からの値を返します。

Boolean SparseBooleanArray.isEmpty()

コレクションに要素が含まれていない場合、true を返します。

Boolean SparseBooleanArray.isNotEmpty()

コレクションに要素が含まれている場合、true を返します。

IntIterator SparseBooleanArray.keyIterator()

コレクションのキーのイテレータを返します。

operator SparseBooleanArray SparseBooleanArray.plus(other: SparseBooleanArray)

other のエントリを追加または置換して、新しいコレクションを作成します。

Unit SparseBooleanArray.putAll(other: SparseBooleanArray)

other のエントリを追加または置換して、このコレクションを更新します。

Boolean SparseBooleanArray.remove(key: Int, value: Boolean)

keyvalue にマッピングされている場合にのみ、キーのエントリを削除します。

operator Unit SparseBooleanArray.set(key: Int, value: Boolean)

コレクションに値を格納するためのインデックス演算子を使用できるようにします。

BooleanIterator SparseBooleanArray.valueIterator()

コレクションの値のイテレータを返します。

android.util.SparseIntArray の場合
operator Boolean SparseIntArray.contains(key: Int)

コレクションに key が含まれている場合、true を返します。

Boolean SparseIntArray.containsKey(key: Int)

コレクションに key が含まれている場合、true を返します。

Boolean SparseIntArray.containsValue(value: Int)

コレクションに value が含まれている場合、true を返します。

Unit SparseIntArray.forEach(action: (key: Int, value: Int) -> Unit)

個々の Key-Value エントリに対して、指定された action を実行します。

Int SparseIntArray.getOrDefault(key: Int, defaultValue: Int)

key に対応する値を返します。値が存在しない場合は、defaultValue を返します。

Int SparseIntArray.getOrElse(key: Int, defaultValue: () -> Int)

key に対応する値を返します。値が存在しない場合は、defaultValue からの値を返します。

Boolean SparseIntArray.isEmpty()

コレクションに要素が含まれていない場合、true を返します。

Boolean SparseIntArray.isNotEmpty()

コレクションに要素が含まれている場合、true を返します。

IntIterator SparseIntArray.keyIterator()

コレクションのキーのイテレータを返します。

operator SparseIntArray SparseIntArray.plus(other: SparseIntArray)

other のエントリを追加または置換して、新しいコレクションを作成します。

Unit SparseIntArray.putAll(other: SparseIntArray)

other のエントリを追加または置換して、このコレクションを更新します。

Boolean SparseIntArray.remove(key: Int, value: Int)

keyvalue にマッピングされている場合にのみ、キーのエントリを削除します。

operator Unit SparseIntArray.set(key: Int, value: Int)

コレクションに値を格納するためのインデックス演算子を使用できるようにします。

IntIterator SparseIntArray.valueIterator()

コレクションの値のイテレータを返します。

android.util.SparseLongArray の場合
operator Boolean SparseLongArray.contains(key: Int)

コレクションに key が含まれている場合、true を返します。

Boolean SparseLongArray.containsKey(key: Int)

コレクションに key が含まれている場合、true を返します。

Boolean SparseLongArray.containsValue(value: Long)

コレクションに value が含まれている場合、true を返します。

Unit SparseLongArray.forEach(action: (key: Int, value: Long) -> Unit)

個々の Key-Value エントリに対して、指定された action を実行します。

Long SparseLongArray.getOrDefault(key: Int, defaultValue: Long)

key に対応する値を返します。値が存在しない場合は、defaultValue を返します。

Long SparseLongArray.getOrElse(key: Int, defaultValue: () -> Long)

key に対応する値を返します。値が存在しない場合は、defaultValue からの値を返します。

Boolean SparseLongArray.isEmpty()

コレクションに要素が含まれていない場合、true を返します。

Boolean SparseLongArray.isNotEmpty()

コレクションに要素が含まれている場合、true を返します。

IntIterator SparseLongArray.keyIterator()

コレクションのキーのイテレータを返します。

operator SparseLongArray SparseLongArray.plus(other: SparseLongArray)

other のエントリを追加または置換して、新しいコレクションを作成します。

Unit SparseLongArray.putAll(other: SparseLongArray)

other のエントリを追加または置換して、このコレクションを更新します。

Boolean SparseLongArray.remove(key: Int, value: Long)

keyvalue にマッピングされている場合にのみ、キーのエントリを削除します。

operator Unit SparseLongArray.set(key: Int, value: Long)

コレクションに値を格納するためのインデックス演算子を使用できるようにします。

LongIterator SparseLongArray.valueIterator()

コレクションの値のイテレータを返します。

kotlin.Double の場合
Half Double.toHalf()

指定された Double を表す Half インスタンスを返します。

kotlin.Float の場合
Half Float.toHalf()

指定された Float を表す Half インスタンスを返します。

kotlin.Pair の場合
Pair<F, S> Pair<F, S>.toAndroidPair()

この kotlin.Pair を Android の Pair として返します。

kotlin.Short の場合
Half Short.toHalf()

指定された Short を表す Half インスタンスを返します。

kotlin.String の場合
Half String.toHalf()

指定された String を表す Half インスタンスを返します。

kotlin.ranges.ClosedRange の場合
Range<T> ClosedRange<T>.toRange()

この ClosedRangeRange として返します。

拡張プロパティ

android.util.LongSparseArray の場合
Int LongSparseArray<T>.size()

コレクションに含まれる Key-Value ペアの数を返します。

android.util.SparseArray の場合
Int SparseArray<T>.size()

コレクションに含まれる Key-Value ペアの数を返します。

android.util.SparseBooleanArray の場合
Int SparseBooleanArray.size()

コレクションに含まれる Key-Value ペアの数を返します。

android.util.SparseIntArray の場合
Int SparseIntArray.size()

コレクションに含まれる Key-Value ペアの数を返します。

android.util.SparseLongArray の場合
Int SparseLongArray.size()

コレクションに含まれる Key-Value エントリの数を返します。

トップレベル関数

LruCache<K, V> lruCache(maxSize: Int, crossinline sizeOf: (key: K, value: V) -> Int = { _, _ -> 1 }, crossinline create: (key: K) -> V? = { null as V? }, crossinline onEntryRemoved: (evicted: Boolean, key: K, oldValue: V, newValue: V?) -> Unit = { _, _, _, _ -> })

指定されたパラメータで LruCache を作成します。

infix Range<T> T.rangeTo(that: T)

この Comparable の値から that までの範囲を作成します。

androidx.core.view

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.view.Menu の場合
operator Boolean Menu.contains(item: MenuItem)

このメニューで item が見つかった場合、true を返します。

Unit Menu.forEach(action: (item: MenuItem) -> Unit)

指定されたアクションをこのメニューの各アイテムに実行します。

Unit Menu.forEachIndexed(action: (index: Int, item: MenuItem) -> Unit)

指定されたアクションをこのメニューの各アイテムに実行し、アイテムの順次インデックスを提供します。

operator MenuItem Menu.get(index: Int)

index のメニューを返します。

Boolean Menu.isEmpty()

メニューにアイテムが含まれていない場合、true を返します。

Boolean Menu.isNotEmpty()

このメニューに 1 つ以上のアイテムが含まれている場合、true を返します。

operator MutableIterator<MenuItem> Menu.iterator()

このメニューに含まれるアイテムの MutableIterator を返します。

operator Unit Menu.minusAssign(item: MenuItem)

このメニューから item を削除します。

android.view.View の場合
Unit View.doOnAttach(crossinline action: (view: View) -> Unit)

このビューがウィンドウにアタッチされたときに、指定されたアクションを実行します。

Unit View.doOnDetach(crossinline action: (view: View) -> Unit)

このビューがウィンドウからデタッチされたときに、指定されたアクションを実行します。

Unit View.doOnLayout(crossinline action: (view: View) -> Unit)

このビューがレイアウトされたときに、指定されたアクションを実行します。

Unit View.doOnNextLayout(crossinline action: (view: View) -> Unit)

このビューが次にレイアウトされたときに、指定されたアクションを実行します。

OneShotPreDrawListener View.doOnPreDraw(crossinline action: (view: View) -> Unit)

ビューツリーが描画される直前に、指定されたアクションを実行します。

Bitmap View.drawToBitmap(config: Config = Bitmap.Config.ARGB_8888)

この ViewBitmap 表現を返します。

Runnable View.postDelayed(delayInMillis: Long, crossinline action: () -> Unit)

View.postDelayed を、パラメータを並べ替えてアクションをかっこの外側に配置できるようにしたバージョン。

Runnable View.postOnAnimationDelayed(delayInMillis: Long, crossinline action: () -> Unit)

View.postOnAnimationDelayed を、パラメータを並べ替えてアクションをかっこの外側に配置できるようにしたバージョン。

Unit View.setPadding(@Px size: Int)

ビューのパディングを設定します。

Unit View.updateLayoutParams(block: LayoutParams.() -> Unit)

View の layoutParams を使用して block を実行し、更新されたバージョンで layoutParams の再割り当てを行います。

Unit View.updateLayoutParams(block: T.() -> Unit)

View の layoutParams の型付きバージョンを使用して block を実行し、更新されたバージョンで layoutParams の再割り当てを行います。

Unit View.updatePadding(@Px left: Int = paddingLeft, @Px top: Int = paddingTop, @Px right: Int = paddingRight, @Px bottom: Int = paddingBottom)

このビューのパディングを更新します。

Unit View.updatePaddingRelative(@Px start: Int = paddingStart, @Px top: Int = paddingTop, @Px end: Int = paddingEnd, @Px bottom: Int = paddingBottom)

このビューの相対パディングを更新します。

android.view.ViewGroup の場合
operator Boolean ViewGroup.contains(view: View)

このビューグループで view が見つかった場合、true を返します。

Unit ViewGroup.forEach(action: (view: View) -> Unit)

指定されたアクションをこのビューグループの各ビューで実行します。

Unit ViewGroup.forEachIndexed(action: (index: Int, view: View) -> Unit)

指定されたアクションをこのビューグループの各ビューで実行し、ビューの順次インデックスを提供します。

operator View ViewGroup.get(index: Int)

index のビューを返します。

Boolean ViewGroup.isEmpty()

ビューグループにビューが含まれていない場合、true を返します。

Boolean ViewGroup.isNotEmpty()

このビューグループに 1 つ以上のビューが含まれている場合、true を返します。

operator MutableIterator<View> ViewGroup.iterator()

このビューグループに含まれるビューの MutableIterator を返します。

operator Unit ViewGroup.minusAssign(view: View)

このビューグループから view を削除します。

operator Unit ViewGroup.plusAssign(view: View)

このビューグループに view を追加します。

android.view.ViewGroup.MarginLayoutParams の場合
Unit MarginLayoutParams.setMargins(@Px size: Int)

ViewGroup の MarginLayoutParams のマージンを設定します。

Unit MarginLayoutParams.updateMargins(@Px left: Int = leftMargin, @Px top: Int = topMargin, @Px right: Int = rightMargin, @Px bottom: Int = bottomMargin)

ViewGroupViewGroup.MarginLayoutParams のマージンを更新します。

Unit MarginLayoutParams.updateMarginsRelative(@Px start: Int = marginStart, @Px top: Int = topMargin, @Px end: Int = marginEnd, @Px bottom: Int = bottomMargin)

ViewGroup の MarginLayoutParams の相対マージンを更新します。

拡張プロパティ

android.view.Menu の場合
Sequence<MenuItem> Menu.children()

このメニューに含まれるアイテムの Sequence を返します。

Int Menu.size()

このメニューに含まれるアイテムの数を返します。

android.view.View の場合
Boolean View.isGone()

このビューの可視性が View.GONE である場合は true を返し、それ以外の場合は false を返します。

Boolean View.isInvisible()

このビューの可視性が View.INVISIBLE である場合は true を返し、それ以外の場合は false を返します。

Boolean View.isVisible()

このビューの可視性が View.VISIBLE である場合は true を返し、それ以外の場合は false を返します。

Int View.marginBottom()

このビューの LayoutParamsViewGroup.MarginLayoutParams である場合は下マージンを返し、それ以外の場合は 0 を返します。

Int View.marginEnd()

このビューの LayoutParamsViewGroup.MarginLayoutParams である場合は終了マージンを返し、それ以外の場合は 0 を返します。

Int View.marginLeft()

このビューの LayoutParamsViewGroup.MarginLayoutParams である場合は左マージンを返し、それ以外の場合は 0 を返します。

Int View.marginRight()

このビューの LayoutParamsViewGroup.MarginLayoutParams である場合は右マージンを返し、それ以外の場合は 0 を返します。

Int View.marginStart()

このビューの LayoutParamsViewGroup.MarginLayoutParams である場合は開始マージンを返し、それ以外の場合は 0 を返します。

Int View.marginTop()

このビューの LayoutParamsViewGroup.MarginLayoutParams である場合は上マージンを返し、それ以外の場合は 0 を返します。

android.view.ViewGroup の場合
Sequence<View> ViewGroup.children()

このビューグループの子ビューの Sequence を返します。

Int ViewGroup.size()

このビューグループに含まれるビューの数を返します。

androidx.core.widget

依存関係

Groovy

dependencies {
    implementation "androidx.core:core-ktx:1.13.1"
}

Kotlin

dependencies {
    implementation("androidx.core:core-ktx:1.13.1")
}

拡張関数

android.widget.TextView の場合
TextWatcher TextView.addTextChangedListener(crossinline beforeTextChanged: (text: CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> }, crossinline onTextChanged: (text: CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> }, crossinline afterTextChanged: (text: Editable?) -> Unit = {})

指定されたアクションを使用して、テキストが変更されたリスナーをこの TextView に追加します。

TextWatcher TextView.doAfterTextChanged(crossinline action: (text: Editable?) -> Unit)

テキストの変更後に起動するアクションを追加します。

TextWatcher TextView.doBeforeTextChanged(crossinline action: (text: CharSequence?, start: Int, count: Int, after: Int) -> Unit)

テキストの変更前に起動するアクションを追加します。

TextWatcher TextView.doOnTextChanged(crossinline action: (text: CharSequence?, start: Int, count: Int, after: Int) -> Unit)

テキストの変更中に起動するアクションを追加します。

androidx.dynamicanimation.animation

依存関係

Groovy

dependencies {
    implementation "androidx.dynamicanimation:dynamicanimation-ktx:1.1.0-alpha03"
}

Kotlin

dependencies {
    implementation("androidx.dynamicanimation:dynamicanimation-ktx:1.1.0-alpha03")
}

拡張関数

SpringAnimation の場合
SpringAnimation SpringAnimation.withSpringForceProperties(func: SpringForce.() -> Unit)

SpringForce.mDampingRatioSpringForce.mfininalPosition、および SpringAnimation の剛性などのばねの力のプロパティを更新または適用します。

トップレベル関数

FlingAnimation flingAnimationOf(setter: (Float) -> Unit, getter: () -> Float)

指定されたセッターとゲッターでアクセスできるプロパティの FlingAnimation を作成します。

SpringAnimation springAnimationOf(setter: (Float) -> Unit, getter: () -> Float, finalPosition: Float = Float.NaN)

指定されたセッターとゲッターでアクセスできるプロパティの SpringAnimation を作成します。

androidx.fragment.app

依存関係

Groovy

dependencies {
    implementation "androidx.fragment:fragment-ktx:1.7.0"
}

Kotlin

dependencies {
    implementation("androidx.fragment:fragment-ktx:1.7.0")
}

拡張関数

android.view.View の場合
F View.findFragment()

View に関連付けられた Fragment を検索します。

Fragment の場合
Lazy<VM> Fragment.activityViewModels(noinline factoryProducer: () -> ViewModelProvider.Factory = null)

親アクティビティの ViewModel にアクセスするプロパティ デリゲートを返します。factoryProducer が指定された場合、それによって返される ViewModelProvider.Factory は初めて ViewModel を作成するために使用されます。

Lazy<VM> Fragment.createViewModelLazy(viewModelClass: KClass<VM>, storeProducer: () -> ViewModelStore, factoryProducer: () -> ViewModelProvider.Factory = null)

factoryProducer として渡された null をデフォルトのファクトリに解決する、ViewModelLazy を作成するためのヘルパー メソッド。

Lazy<VM> Fragment.viewModels(noinline ownerProducer: () -> ViewModelStoreOwner = { this }, noinline factoryProducer: () -> ViewModelProvider.Factory = null)

この Fragment にスコープ設定された defaultViewModel にアクセスするプロパティ デリゲートを返します。

FragmentTransaction の場合
FragmentTransaction FragmentTransaction.add(@IdRes containerViewId: Int, tag: String? = null, args: Bundle? = null)

関連付けられた FragmentManager にフラグメントを追加し、後で FragmentManager.findFragmentById を使用して取得するために、Fragment のビューを containerViewId で指定されたコンテナビューにインフレートします。

FragmentTransaction FragmentTransaction.add(tag: String, args: Bundle? = null)

Fragment をコンテナビューに追加せずに、関連付けられた FragmentManager にフラグメントを追加します。

FragmentTransaction FragmentTransaction.replace(@IdRes containerViewId: Int, tag: String? = null, args: Bundle? = null)

コンテナに追加された既存のフラグメントを置換します。

FragmentManager の場合
Unit FragmentManager.commit(allowStateLoss: Boolean = false, body: FragmentTransaction.() -> Unit)

FragmentTransaction 内で body を実行します。これは、例外を発生させずに完了すると自動的に commit されます。

Unit FragmentManager.commitNow(allowStateLoss: Boolean = false, body: FragmentTransaction.() -> Unit)

FragmentTransaction 内で body を実行します。これは、例外を発生させずに完了すると自動的に commit されます。

Unit FragmentManager.transaction(now: Boolean = false, allowStateLoss: Boolean = false, body: FragmentTransaction.() -> Unit)

FragmentTransaction 内で body を実行します。これは、例外を発生させずに完了すると自動的に commit されます。

androidx.fragment.app.testing

依存関係

Groovy

dependencies {
    implementation "androidx.fragment:fragment-testing:1.7.0"
}

Kotlin

dependencies {
    implementation("androidx.fragment:fragment-testing:1.7.0")
}

トップレベル関数

FragmentScenario<F!> launchFragment(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, factory: FragmentFactory? = null)

指定された FragmentFactory を使用して、空の FragmentActivity によりホストされている指定された引数で Fragment を起動し、再開状態になるのを待ちます。

FragmentScenario<F!> launchFragment(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, crossinline instantiate: () -> F)

Fragment を作成する instantiate を使用して、空の FragmentActivity によりホストされている指定された引数で Fragment を起動し、再開状態になるのを待ちます。

FragmentScenario<F!> launchFragmentInContainer(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, factory: FragmentFactory? = null)

空の FragmentActivity によりホストされている指定された引数で、Activity のルートビュー コンテナ android.R.id.content 内の Fragment を起動し、再開状態になるのを待ちます。

FragmentScenario<F!> launchFragmentInContainer(fragmentArgs: Bundle? = null, @StyleRes themeResId: Int = R.style.FragmentScenarioEmptyFragmentActivityTheme, crossinline instantiate: () -> F)

Fragment を作成する instantiate を使用して、空の FragmentActivity によりホストされている指定された引数で、Activity のルートビュー コンテナ android.R.id.content 内の Fragment を起動し、再開状態になるのを待ちます。

androidx.lifecycle

依存関係

Groovy

dependencies {
    implementation "androidx.lifecycle:lifecycle-livedata-core-ktx:2.7.0"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.7.0"
    implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:2.7.0"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.7.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0"
}

Kotlin

dependencies {
    implementation("androidx.lifecycle:lifecycle-livedata-core-ktx:2.7.0")
    implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
    implementation("androidx.lifecycle:lifecycle-reactivestreams-ktx:2.7.0")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
    implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
}

拡張関数

kotlinx.coroutines.flow.Flow の場合
LiveData<T> Flow<T>.asLiveData(context: CoroutineContext = EmptyCoroutineContext, timeoutInMs: Long = DEFAULT_TIMEOUT)

発生元の Flow から収集された値を持つ LiveData を作成します。

LiveData<T> Flow<T>.asLiveData(context: CoroutineContext = EmptyCoroutineContext, timeout: Duration)

発生元の Flow から収集された値を持つ LiveData を作成します。

org.reactivestreams.Publisher の場合
LiveData<T> Publisher<T>.toLiveData()

ReactiveStreams Publisher から Observable 型の LiveData ストリームを作成します。

LiveData の場合
Flow<T> LiveData<T>.asFlow()

発生元の LiveData によりディスパッチされた値を含む Flow を作成します。フローコレクタはまず LiveData で保持される最新の値を受け取り、その後 LiveData の更新を監視します。

LiveData<X> LiveData<X>.distinctUntilChanged()

ソースの this LiveData の値が変更されるまで値を出力しない新規の LiveData オブジェクトを作成します。

LiveData<Y> LiveData<X>.map(crossinline transform: (X) -> Y)

this LiveData に設定された個々の値に transform を適用することにより、this LiveData からマッピングされた LiveData を返します。

Observer<T> LiveData<T>.observe(owner: LifecycleOwner, crossinline onChanged: (T) -> Unit)

指定された onChanged ラムダを、指定された owner の存続期間中のオブザーバーとして追加し、オブザーバーへの参照を返します。

LiveData<Y> LiveData<X>.switchMap(crossinline transform: (X) -> LiveData<Y>)

this に設定された個々の値に transform を適用することにより、入力の this LiveData からマッピングされた LiveData を返します。

Publisher<T> LiveData<T>.toPublisher(lifecycle: LifecycleOwner)

指定された LiveData ストリームを ReactiveStreams Publisher に適用します。

ViewModelProvider の場合
VM ViewModelProvider.get()

既存の ViewModel を返します。または、この ViewModelProvider に関連付けられたスコープ(通常はフラグメントまたはアクティビティ)内に新しい ViewModel を作成します。

LifecycleOwner の場合
suspend T LifecycleOwner.whenCreated(block: suspend CoroutineScope.() -> T)

LifecycleOwnerLifecycle が少なくとも Lifecycle.State.CREATED 状態にあるときに、指定された block を実行します。

suspend T LifecycleOwner.whenResumed(block: suspend CoroutineScope.() -> T)

LifecycleOwnerLifecycle が少なくとも Lifecycle.State.RESUMED 状態にあるときに、指定された block を実行します。

suspend T LifecycleOwner.whenStarted(block: suspend CoroutineScope.() -> T)

LifecycleOwnerLifecycle が少なくとも Lifecycle.State.STARTED 状態にあるときに、指定された block を実行します。

Lifecycle の場合
suspend T Lifecycle.whenCreated(block: suspend CoroutineScope.() -> T)

Lifecycle が少なくとも Lifecycle.State.CREATED 状態にあるときに、指定された block を実行します。

suspend T Lifecycle.whenResumed(block: suspend CoroutineScope.() -> T)

Lifecycle が少なくとも Lifecycle.State.RESUMED 状態にあるときに、指定された block を実行します。

suspend T Lifecycle.whenStarted(block: suspend CoroutineScope.() -> T)

Lifecycle が少なくとも Lifecycle.State.STARTED 状態にあるときに、指定された block を実行します。

suspend T Lifecycle.whenStateAtLeast(minState: Lifecycle.State, block: suspend CoroutineScope.() -> T)

指定された block を、メインスレッドで block を実行する CoroutineDispatcher で実行し、Lifecycle の状態が少なくとも minState でない場合は実行を中断します。

拡張プロパティ

Lifecycle の場合
LifecycleCoroutineScope Lifecycle.coroutineScope()

CoroutineScope は、この Lifecycle に関連付けられます。

LifecycleOwner の場合
LifecycleCoroutineScope LifecycleOwner.lifecycleScope()

CoroutineScope は、この LifecycleOwnerLifecycle に関連付けられます。

ViewModel の場合
CoroutineScope ViewModel.viewModelScope()

CoroutineScope は、この ViewModel に関連付けられます。

トップレベル関数

LiveData<T> liveData(context: CoroutineContext = EmptyCoroutineContext, timeoutInMs: Long = DEFAULT_TIMEOUT, block: suspend LiveDataScope<T>.() -> Unit)

LiveDataScope で実行される指定された block から出力される値を持つ LiveData を構築します。

LiveData<T> liveData(context: CoroutineContext = EmptyCoroutineContext, timeout: Duration, block: suspend LiveDataScope<T>.() -> Unit)

LiveDataScope で実行される指定された block から出力される値を持つ LiveData を構築します。

androidx.navigation

依存関係

Groovy

dependencies {
    implementation "androidx.navigation:navigation-runtime-ktx:2.7.7"
    implementation "androidx.navigation:navigation-fragment-ktx:2.7.7"
    implementation "androidx.navigation:navigation-ui-ktx:2.7.7"
}

Kotlin

dependencies {
    implementation("androidx.navigation:navigation-runtime-ktx:2.7.7")
    implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
    implementation("androidx.navigation:navigation-ui-ktx:2.7.7")
}

拡張関数

android.app.Activity の場合
NavController Activity.findNavController(@IdRes viewId: Int)

指定されたビューの ID とそれに含まれる ActivityNavController を検索します。

NavArgsLazy<Args> Activity.navArgs()

Activity のエクストラにアクセスする Lazy デリゲートを Args インスタンスとして返します。

android.view.View の場合
NavController View.findNavController()

View に関連付けられた NavController を検索します。

NavGraphBuilder の場合
Unit NavGraphBuilder.activity(@IdRes id: Int, builder: ActivityNavigatorDestinationBuilder.() -> Unit)

新しい ActivityNavigator.Destination を作成します。

Unit NavGraphBuilder.navigation(@IdRes id: Int, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

ネストされた NavGraph を作成します。

NavGraph の場合
operator Boolean NavGraph.contains(@IdRes id: Int)

このナビゲーション グラフで id の宛先が見つかった場合、true を返します。

operator NavDestination NavGraph.get(@IdRes id: Int)

id の宛先を返します。

operator Unit NavGraph.minusAssign(node: NavDestination)

このナビゲーション グラフから node を削除します。

operator Unit NavGraph.plusAssign(node: NavDestination)

この NavGraph に宛先を追加します。

operator Unit NavGraph.plusAssign(other: NavGraph)

別のコレクションのすべての宛先をこの宛先に追加します。

NavController の場合
NavGraph NavController.createGraph(@IdRes id: Int = 0, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

新しい NavGraph を作成します。

NavHost の場合
NavGraph NavHost.createGraph(@IdRes id: Int = 0, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

新しい NavGraph を作成します。

NavigatorProvider の場合
operator T NavigatorProvider.get(name: String)

登録済みの Navigator を名前で取得します。

operator T NavigatorProvider.get(clazz: KClass<T>)

Navigator.Name アノテーションで指定された名前を使用して、登録済みの Navigator を取得します。

NavGraph NavigatorProvider.navigation(@IdRes id: Int = 0, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

新しい NavGraph を作成します。

operator Unit NavigatorProvider.plusAssign(navigator: Navigator<out NavDestination>)

Navigator.Name アノテーションで指定された名前を使用して、ナビゲータを登録します。

operator Navigator<out NavDestination!>? NavigatorProvider.set(name: String, navigator: Navigator<out NavDestination>)

名前で Navigator を登録します。

Fragment の場合
Lazy<VM> Fragment.navGraphViewModels(@IdRes navGraphId: Int, noinline factoryProducer: () -> ViewModelProvider.Factory = null)

{@link NavController} バックスタックに存在するナビゲーション グラフにスコープ設定された ViewModel にアクセスするプロパティ デリゲートを返します。

トップレベル関数

ActivityNavigator.Extras ActivityNavigatorExtras(activityOptions: ActivityOptionsCompat? = null, flags: Int = 0)

特定の ActivityOptionsCompat インスタンスおよび / または任意の Intent.FLAG_ACTIVITY_ フラグで、新しい ActivityNavigator.Extras インスタンスを作成します。

NavOptions navOptions(optionsBuilder: NavOptionsBuilder.() -> Unit)

新しい NavOptions を作成します。

androidx.navigation.fragment

依存関係

Groovy

dependencies {
    implementation "androidx.navigation:navigation-fragment-ktx:2.7.7"
}

Kotlin

dependencies {
    implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
}

拡張関数

NavGraphBuilder の場合
Unit NavGraphBuilder.dialog(@IdRes id: Int)

新しい DialogFragmentNavigator.Destination を作成します。

Unit NavGraphBuilder.dialog(@IdRes id: Int, builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit)

新しい DialogFragmentNavigator.Destination を作成します。

Unit NavGraphBuilder.fragment(@IdRes id: Int)

新しい FragmentNavigator.Destination を作成します。

Unit NavGraphBuilder.fragment(@IdRes id: Int, builder: FragmentNavigatorDestinationBuilder.() -> Unit)

新しい FragmentNavigator.Destination を作成します。

Fragment の場合
NavController Fragment.findNavController()

指定された FragmentNavController を検索します。

NavArgsLazy<Args> Fragment.navArgs()

Fragment の引数にアクセスする Lazy デリゲートを Args インスタンスとして返します。

トップレベル関数

FragmentNavigator.Extras FragmentNavigatorExtras(vararg sharedElements: Pair<View, String>)

指定された共有要素で新しい FragmentNavigator.Extras インスタンスを作成します。

androidx.navigation.ui

依存関係

Groovy

dependencies {
    implementation "androidx.navigation:navigation-ui-ktx:2.7.7"
}

Kotlin

dependencies {
    implementation("androidx.navigation:navigation-ui-ktx:2.7.7")
}

拡張関数

android.view.MenuItem の場合
Boolean MenuItem.onNavDestinationSelected(navController: NavController)

この MenuItem に関連付けられた NavDestination への移動を試みます。

androidx.appcompat.app.AppCompatActivity の場合
Unit AppCompatActivity.setupActionBarWithNavController(navController: NavController, drawerLayout: DrawerLayout?)

NavController で使用できるように、AppCompatActivity.getSupportActionBar によって返された ActionBar を設定します。

Unit AppCompatActivity.setupActionBarWithNavController(navController: NavController, configuration: AppBarConfiguration = AppBarConfiguration(navController.graph))

NavController で使用できるように、AppCompatActivity.getSupportActionBar によって返された ActionBar を設定します。

androidx.appcompat.widget.Toolbar の場合
Unit Toolbar.setupWithNavController(navController: NavController, drawerLayout: DrawerLayout?)

NavController で使用できるように Toolbar を設定します。

Unit Toolbar.setupWithNavController(navController: NavController, configuration: AppBarConfiguration = AppBarConfiguration(navController.graph))

NavController で使用できるように Toolbar を設定します。

com.google.android.material.appbar.CollapsingToolbarLayout の場合
Unit CollapsingToolbarLayout.setupWithNavController(toolbar: Toolbar, navController: NavController, drawerLayout: DrawerLayout?)

NavController で使用できるように CollapsingToolbarLayoutToolbar を設定します。

Unit CollapsingToolbarLayout.setupWithNavController(toolbar: Toolbar, navController: NavController, configuration: AppBarConfiguration = AppBarConfiguration(navController.graph))

NavController で使用できるように CollapsingToolbarLayoutToolbar を設定します。

com.google.android.material.bottomnavigation.BottomNavigationView の場合
Unit BottomNavigationView.setupWithNavController(navController: NavController)

NavController で使用できるように BottomNavigationView を設定します。

com.google.android.material.navigation.NavigationView の場合
Unit NavigationView.setupWithNavController(navController: NavController)

NavController で使用できるように NavigationView を設定します。

NavController の場合
Boolean NavController.navigateUp(drawerLayout: DrawerLayout?)

ボタンの動作を指定された NavController に委任することにより、「上へ」ボタンを処理します。

Boolean NavController.navigateUp(appBarConfiguration: AppBarConfiguration)

ボタンの動作を指定された NavController に委任することにより、「上へ」ボタンを処理します。

トップレベル関数

AppBarConfiguration AppBarConfiguration(navGraph: NavGraph, drawerLayout: DrawerLayout? = null, noinline fallbackOnNavigateUpListener: () -> Boolean = { false })

android.support.v7.widget.Toolbarandroid.support.design.widget.CollapsingToolbarLayoutandroid.support.v7.app.ActionBar などのアプリバー パターンの実装とやり取りする NavigationUI メソッドの構成オプション。

AppBarConfiguration AppBarConfiguration(topLevelMenu: Menu, drawerLayout: DrawerLayout? = null, noinline fallbackOnNavigateUpListener: () -> Boolean = { false })

android.support.v7.widget.Toolbarandroid.support.design.widget.CollapsingToolbarLayoutandroid.support.v7.app.ActionBar などのアプリバー パターンの実装とやり取りする NavigationUI メソッドの構成オプション。

AppBarConfiguration AppBarConfiguration(topLevelDestinationIds: Set<Int>, drawerLayout: DrawerLayout? = null, noinline fallbackOnNavigateUpListener: () -> Boolean = { false })

android.support.v7.widget.Toolbarandroid.support.design.widget.CollapsingToolbarLayoutandroid.support.v7.app.ActionBar などのアプリバー パターンの実装とやり取りする NavigationUI メソッドの構成オプション。

androidx.paging

依存関係

Groovy

dependencies {
    implementation "androidx.paging:paging-common-ktx:2.1.2"
    implementation "androidx.paging:paging-runtime-ktx:2.1.2"
    implementation "androidx.paging:paging-rxjava2-ktx:2.1.2"
}

Kotlin

dependencies {
    implementation("androidx.paging:paging-common-ktx:2.1.2")
    implementation("androidx.paging:paging-runtime-ktx:2.1.2")
    implementation("androidx.paging:paging-rxjava2-ktx:2.1.2")
}

拡張関数

Factory の場合
Flowable<PagedList<Value>> DataSource.Factory<Key, Value>.toFlowable(config: PagedList.Config, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchScheduler: Scheduler? = null, notifyScheduler: Scheduler? = null, backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST)

RxPagedListBuilder の便宜のため、この DataSource.Factory から Flowable<PagedList> を作成します。

Flowable<PagedList<Value>> DataSource.Factory<Key, Value>.toFlowable(pageSize: Int, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchScheduler: Scheduler? = null, notifyScheduler: Scheduler? = null, backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST)

RxPagedListBuilder の便宜のため、この DataSource.Factory から Flowable<PagedList> を作成します。

LiveData<PagedList<Value>> DataSource.Factory<Key, Value>.toLiveData(config: PagedList.Config, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchExecutor: Executor = ArchTaskExecutor.getIOThreadExecutor())

LivePagedListBuilder の便宜のため、この DataSource.Factory から LiveData<PagedList> を作成します。

LiveData<PagedList<Value>> DataSource.Factory<Key, Value>.toLiveData(pageSize: Int, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchExecutor: Executor = ArchTaskExecutor.getIOThreadExecutor())

LivePagedListBuilder の便宜のため、この DataSource.Factory から LiveData<PagedList> を作成します。

Observable<PagedList<Value>> DataSource.Factory<Key, Value>.toObservable(config: PagedList.Config, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchScheduler: Scheduler? = null, notifyScheduler: Scheduler? = null)

RxPagedListBuilder の便宜のため、この DataSource.Factory から Observable<PagedList> を作成します。

Observable<PagedList<Value>> DataSource.Factory<Key, Value>.toObservable(pageSize: Int, initialLoadKey: Key? = null, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, fetchScheduler: Scheduler? = null, notifyScheduler: Scheduler? = null)

RxPagedListBuilder の便宜のため、この DataSource.Factory から Observable<PagedList> を作成します。

トップレベル関数

PagedList.Config Config(pageSize: Int, prefetchDistance: Int = pageSize, enablePlaceholders: Boolean = true, initialLoadSizeHint: Int = pageSize * PagedList.Config.Builder.DEFAULT_INITIAL_PAGE_MULTIPLIER, maxSize: Int = PagedList.Config.MAX_SIZE_UNBOUNDED)

PagedList.Config.Builder の便宜のため、PagedList.Config を作成します。

PagedList<Value> PagedList(dataSource: DataSource<Key, Value>, config: PagedList.Config, notifyExecutor: Executor, fetchExecutor: Executor, boundaryCallback: PagedList.BoundaryCallback<Value>? = null, initialKey: Key? = null)

PagedList.Builder の便宜のため、PagedList を作成します。

androidx.palette.graphics

依存関係

Groovy

dependencies {
    implementation "androidx.palette:palette-ktx:1.0.0"
}

Kotlin

dependencies {
    implementation("androidx.palette:palette-ktx:1.0.0")
}

拡張関数

Palette の場合
operator Palette.Swatch? Palette.get(target: Target)

指定されたターゲットの選択された見本をパレットから返します。見つからなかった場合は null を返します。

androidx.preference

依存関係

Groovy

dependencies {
    implementation "androidx.preference:preference-ktx:1.2.1"
}

Kotlin

dependencies {
    implementation("androidx.preference:preference-ktx:1.2.1")
}

拡張関数

PreferenceGroup の場合
operator Boolean PreferenceGroup.contains(preference: Preference)

この優先設定グループで preference が見つかった場合、true を返します。

Unit PreferenceGroup.forEach(action: (preference: Preference) -> Unit)

この優先設定グループに含まれる各優先設定で、指定されたアクションを実行します。

Unit PreferenceGroup.forEachIndexed(action: (index: Int, preference: Preference) -> Unit)

この優先設定グループに含まれる各優先設定で、指定されたアクションを実行し、優先設定の順次インデックスを提供します。

operator T? PreferenceGroup.get(key: CharSequence)

key を含む優先設定を返します。key を含む優先設定が見つからなかった場合は、null を返します。

operator Preference PreferenceGroup.get(index: Int)

index の優先設定を返します。

Boolean PreferenceGroup.isEmpty()

この優先設定グループに優先設定が含まれていない場合、true を返します。

Boolean PreferenceGroup.isNotEmpty()

この優先設定グループに 1 つ以上の優先設定が含まれている場合、true を返します。

operator MutableIterator<Preference> PreferenceGroup.iterator()

この優先設定グループに含まれる優先設定の MutableIterator を返します。

operator Unit PreferenceGroup.minusAssign(preference: Preference)

この優先設定グループから preference を削除します。

operator Unit PreferenceGroup.plusAssign(preference: Preference)

この優先設定グループに preference を追加します。

拡張プロパティ

PreferenceGroup の場合
Sequence<Preference> PreferenceGroup.children()

この優先設定グループに含まれる優先設定の Sequence を返します。

Int PreferenceGroup.size()

この優先設定グループに含まれる優先設定の数を返します。

androidx.room

依存関係

Groovy

dependencies {
    implementation "androidx.room:room-ktx:2.6.1"
}

Kotlin

dependencies {
    implementation("androidx.room:room-ktx:2.6.1")
}

拡張関数

RoomDatabase の場合
suspend R RoomDatabase.withTransaction(block: suspend () -> R)

データベース トランザクション内で、指定された中断中の block を呼び出します。

androidx.slice.builders

依存関係

Groovy

dependencies {
    implementation "androidx.slice:slice-builders-ktx:1.0.0-alpha08"
}

Kotlin

dependencies {
    implementation("androidx.slice:slice-builders-ktx:1.0.0-alpha08")
}

拡張関数

GridRowBuilderDsl の場合
GridRowBuilder GridRowBuilderDsl.cell(buildCell: CellBuilderDsl.() -> Unit)

GridRowBuilder GridRowBuilderDsl.seeMoreCell(buildCell: CellBuilderDsl.() -> Unit)

ListBuilderDsl の場合
ListBuilder ListBuilderDsl.gridRow(buildGrid: GridRowBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.header(buildHeader: HeaderBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.inputRange(buildInputRange: InputRangeBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.range(buildRange: RangeBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.row(buildRow: RowBuilderDsl.() -> Unit)

ListBuilder ListBuilderDsl.seeMoreRow(buildRow: RowBuilderDsl.() -> Unit)

トップレベル関数

Slice list(context: Context, uri: Uri, ttl: Long, addRows: ListBuilderDsl.() -> Unit)

Kotlin で Slice を構築するのに必要な詳細度を減らします。

SliceAction tapSliceAction(pendingIntent: PendingIntent, icon: IconCompat, imageMode: Int = ICON_IMAGE, title: CharSequence)

タップ可能な SliceAction を構築するファクトリ メソッド。

SliceAction toggleSliceAction(pendingIntent: PendingIntent, icon: IconCompat? = null, title: CharSequence, isChecked: Boolean)

トグル可能な SliceAction を構築するファクトリ メソッド。

androidx.sqlite.db

依存関係

Groovy

dependencies {
    implementation "androidx.sqlite:sqlite-ktx:2.4.0"
}

Kotlin

dependencies {
    implementation("androidx.sqlite:sqlite-ktx:2.4.0")
}

拡張関数

SupportSQLiteDatabase の場合
T SupportSQLiteDatabase.transaction(exclusive: Boolean = true, body: SupportSQLiteDatabase.() -> T)

トランザクション内で body を実行し、例外を発生させずに完了した場合は成功としてマークします。

androidx.work

依存関係

拡張関数

com.google.common.util.concurrent.ListenableFuture の場合
suspend R ListenableFuture<R>.await()

スレッドをブロックせずに ListenableFuture の完了を待機します。

Operation の場合
suspend Operation.State.SUCCESS! Operation.await()

スレッドをブロックせずに Operation を待機します。

Data の場合
Boolean Data.hasKeyWithValueOfType(key: String)

Data のインスタンスが、指定された key に対応する、期待される型 T の値を持つ場合、true を返します。

Builder の場合
OneTimeWorkRequest.Builder OneTimeWorkRequest.Builder.setInputMerger(@NonNull inputMerger: KClass<out InputMerger>)

OneTimeWorkRequest.BuilderInputMerger を設定します。

トップレベル関数

OneTimeWorkRequest.Builder OneTimeWorkRequestBuilder()

指定された ListenableWorkerOneTimeWorkRequest を作成します。

PeriodicWorkRequest.Builder PeriodicWorkRequestBuilder(repeatInterval: Long, repeatIntervalTimeUnit: TimeUnit)

指定された ListenableWorkerPeriodicWorkRequest.Builder を作成します。

PeriodicWorkRequest.Builder PeriodicWorkRequestBuilder(repeatInterval: Duration)

指定された ListenableWorkerPeriodicWorkRequest.Builder を作成します。

PeriodicWorkRequest.Builder PeriodicWorkRequestBuilder(repeatInterval: Long, repeatIntervalTimeUnit: TimeUnit, flexTimeInterval: Long, flexTimeIntervalUnit: TimeUnit)

指定された ListenableWorkerPeriodicWorkRequest.Builder を作成します。

PeriodicWorkRequest.Builder PeriodicWorkRequestBuilder(repeatInterval: Duration, flexTimeInterval: Duration)

指定された ListenableWorkerPeriodicWorkRequest.Builder を作成します。

Data workDataOf(vararg pairs: Pair<String, Any?>)

ペアのリストを Data オブジェクトに変換します。

androidx.work.testing

依存関係

Groovy

dependencies {
    implementation "androidx.work:work-testing:2.9.0"
}

Kotlin

dependencies {
    implementation("androidx.work:work-testing:2.9.0")
}

トップレベル関数

TestListenableWorkerBuilder<W> TestListenableWorkerBuilder(context: Context, inputData: Data = Data.EMPTY, tags: List<String> = emptyList(), runAttemptCount: Int = 1, triggeredContentUris: List<Uri> = emptyList(), triggeredContentAuthorities: List<String> = emptyList())

TestListenableWorkerBuilder のインスタンスを構築します。

TestWorkerBuilder<W> TestWorkerBuilder(context: Context, executor: Executor, inputData: Data = Data.EMPTY, tags: List<String> = emptyList(), runAttemptCount: Int = 1, triggeredContentUris: List<Uri> = emptyList(), triggeredContentAuthorities: List<String> = emptyList())

TestWorkerBuilder のインスタンスを構築します。

com.google.android.play.core.ktx

依存関係

Groovy

dependencies {
    implementation "com.google.android.play:core-ktx:1.8.1"
}

Kotlin

dependencies {
    implementation("com.google.android.play:core-ktx:1.8.1")
}

拡張関数

com.google.android.play.core.appupdate.AppUpdateManager の場合
suspend AppUpdateInfo AppUpdateManager.requestAppUpdateInfo()

現在のアプリのアップデートの可用性をリクエストします。

suspend Unit AppUpdateManager.requestCompleteUpdate()

フレキシブル アップデート フローで、アップデートの完了をトリガーします。

Flow<AppUpdateResult> AppUpdateManager.requestUpdateFlow()

アップデートの可用性と進行状況をモニタリングするためのエントリ ポイント。

Boolean AppUpdateManager.startUpdateFlowForResult(appUpdateInfo: AppUpdateInfo, appUpdateType: Int, fragment: Fragment, requestCode: Int)

AppUpdateManager.startUpdateFlowForResult の、結果を返すための AndroidX の Fragment を受け入れるバージョン。

com.google.android.play.core.splitinstall.SplitInstallManager の場合
suspend Unit SplitInstallManager.requestCancelInstall(sessionId: Int)

SplitInstallManager.cancelInstall の suspend バージョン。

suspend Unit SplitInstallManager.requestDeferredInstall(moduleNames: List<String>)

SplitInstallManager.deferredInstall の suspend バージョン。

suspend Unit SplitInstallManager.requestDeferredLanguageInstall(languages: List<Locale>)

SplitInstallManager.deferredLanguageInstall の suspend バージョン。

suspend Unit SplitInstallManager.requestDeferredLanguageUninstall(languages: List<Locale>)

SplitInstallManager.deferredLanguageUninstall の suspend バージョン。

suspend Unit SplitInstallManager.requestDeferredUninstall(moduleNames: List<String>)

SplitInstallManager.deferredUninstall の suspend バージョン。

suspend Int SplitInstallManager.requestInstall(modules: List<String> = listOf(), languages: List<String> = listOf())

リクエストされたモジュール / 言語のインストールを開始します。

Flow<SplitInstallSessionState> SplitInstallManager.requestProgressFlow()

進行中の分割インストールの進行状況イベントをすべて配信するバッファリングされたフローを作成して返します。

suspend SplitInstallSessionState SplitInstallManager.requestSessionState(sessionId: Int)

SplitInstallManager.getSessionState の suspend バージョン。

suspend List<SplitInstallSessionState> SplitInstallManager.requestSessionStates()

SplitInstallManager.getSessionStates の suspend バージョン。

Boolean SplitInstallManager.startConfirmationDialogForResult(sessionState: SplitInstallSessionState, fragment: Fragment, requestCode: Int)

SplitInstallManager.startConfirmationDialogForResult の、結果を返すための AndroidX の Fragment を受け入れるバージョン。

拡張プロパティ

com.google.android.play.core.appupdate.AppUpdateInfo の場合
Int AppUpdateInfo.installStatus()

アップデートの進行状況ステータスを返します。

Boolean AppUpdateInfo.isFlexibleUpdateAllowed()

フレキシブル アップデートが許可されている場合、true を返します。

Boolean AppUpdateInfo.isImmediateUpdateAllowed()

即時アップデートが許可されている場合、true を返します。

com.google.android.play.core.install.InstallState の場合
Boolean InstallState.hasTerminalStatus()

これが最終ステータスである(これ以上アップデートはない)ことと、ステータス(成功、キャンセル、失敗のいずれか)に応じて処理が必要であることを示します。

Int InstallState.installErrorCode()

インストールのエラーコード、つまり {@link InstallErrorCode#NO_ERROR} を返します。

Int InstallState.installStatus()

インストールのステータスを返します。

String! InstallState.packageName()

インストール中のアプリのパッケージ名を返します。

com.google.android.play.core.splitinstall.SplitInstallSessionState の場合
Long SplitInstallSessionState.bytesDownloaded()

このアップデートによってダウンロードされるバイト数。

Int SplitInstallSessionState.errorCode()

このアップデートのエラーコード。

Boolean SplitInstallSessionState.hasTerminalStatus()

このアップデートが最終である(つまり、これ以上このセッションでのアップデートはない)ことを示します。

List<String> SplitInstallSessionState.languages()

このアップデートに含まれる言語。

List<String> SplitInstallSessionState.moduleNames()

このアップデートに含まれるモジュール。

Int SplitInstallSessionState.sessionId()

このアップデートのセッション ID。

Int SplitInstallSessionState.status()

このアップデートのステータス コード。

Long SplitInstallSessionState.totalBytesToDownload()

このアップデートでダウンロードされる合計バイト数。

トップレベル関数

SplitInstallStateUpdatedListener SplitInstallStateUpdatedListener(onRequiresConfirmation: (SplitInstallSessionState) -> Unit, onInstalled: (SplitInstallSessionState) -> Unit, onFailed: (SplitInstallSessionState) -> Unit = {}, onPending: (SplitInstallSessionState) -> Unit = {}, onDownloaded: (SplitInstallSessionState) -> Unit = {}, onDownloading: (SplitInstallSessionState) -> Unit = {}, onInstalling: (SplitInstallSessionState) -> Unit = {}, onCanceling: (SplitInstallSessionState) -> Unit = {}, onCanceled: (SplitInstallSessionState) -> Unit = {}, onNonTerminalStatus: (SplitInstallSessionState) -> Unit = {}, onTerminalStatus: (SplitInstallSessionState) -> Unit = {})

SplitInstallStateUpdatedListener を作成するための便利な関数。