



In this case, the component would inherit the generic View class and override functions like onMeasure() to determine its layout, onDraw() to display its contents, etc. The most versatile and most complex approach is to create a self drawn component. This approach could also make use of the previous one, i.e., the internal components could be native or custom. For example, a LabeledEditText that inherits LinearLayout with horizontal orientation, and contains both a TextView acting as a label and an EditText acting as a text entry field. This approach usually takes advantage of Layouts to control how the components are arranged on the screen. For example, a CircleImageView that inherits ImageView, overriding the onDraw() function to restrict the displayed image to a circle, and adding a loadFromFile() function to load an image from external memory.Ĭreate a compound component out of several components. TextView, ImageView, etc.), and add/override needed functionality. The Android UI model is inherently customizable, offering the means of Android customization, testing, and the ability to create custom UI components in various ways: The answer to both scenarios is a custom UI component. It is not uncommon for developers to find themselves in need of a UI component that is either not provided by the platform they are targeting or is, indeed, provided, but lacks a certain property or behavior.
