Entradas

Mostrando las entradas de mayo, 2019

Android Custom View Tutorial

Imagen
Create an Android Custom View in Kotlin and learn how to draw shapes on the canvas, make views responsive, create new XML attributes, and save view state Custom View and Custom ViewGroup What is a custom View? Sometimes you want to show a certain type of data and there is already a suitable view in the basic widget set. But if you want UI customization or a different user interaction, you may need to extend a widget. Suppose that there were no Button widget in the basic widget set in the Android SDK and you want to make one. You would extend the TextView class to get all the capabilities related to the text like setting text, text color, text size, text style and so on. Then you will start your customization work, to give your new widget the look and feel of a button. this is what happens in the Android SDK the Button class extends the TextView class. Or you could in theory extend the View class to start from scratch. What is a custom ViewGroup? Sometimes you want to group so...