Google releases Kotlin Android Extensions (Android KTX) for developers
News / Mar 1, 2018
Google releases preview of Android KTX for Android that is as per google - “more concise, idiomatic, and pleasant.”
Android Kotlin extensions uses package names that begin with androidx. Kotlin extensions helps developers to write shorter and cleaner code.
An examples of how Android KTX can help developers write more natural and concise Kotlin code.
Translating path difference
In the code below, we translate the difference between two paths by 100px.
Kotlin | Kotlin with Android KTX |
val pathDifference = Path(myPath1).apply { op(myPath2, Path.Op.DIFFERENCE) } val myPaint = Paint() canvas.apply { val checkpoint = save() translate(0F, 100F) drawPath(pathDifference, myPaint) restoreToCount(checkpoint) } |
val pathDifference = myPath1 - myPath2 canvas.withTranslation(y = 100F) { drawPath(pathDifference, myPaint) } |
Read more about the features on its blog and the android KTX that covers the Android framework is available on GitHub.
Latest
SOLID Principles: A Comprehensive Guide with Examples
Dec 22, 2024
React useEffect, useMemo, and useCallback: A Comprehensive Guide
Nov 23, 2024
React Component Structure, Composition, HOCs and Optimization with Examples
Oct 4, 2023
How to copy text to the clipboard in React.js
Sep 29, 2023
News
Pure html popover API is coming in Chromium 114
Sep 24, 2023
GitHub and OpenAI launch Copilot - an AI pair programmer
Jul 1, 2021
CSS aspect-ratio property
Jan 31, 2021
AWS UI - a collection of React components
Jan 20, 2021
Featured
SOLID Principles: A Comprehensive Guide with Examples
Dec 22, 2024
React useEffect, useMemo, and useCallback: A Comprehensive Guide
Nov 23, 2024
Axios Interceptors in a React application
May 27, 2023
Mastering Laravel: Exploring the Power of implode() and explode() Functions for String Manipulation
May 22, 2023