-
Notifications
You must be signed in to change notification settings - Fork 55
What to extend
Usually, you can judge that by looking at the design. If the view looks like one of the basic, Android views but with a special feature, it probably can be done by extending that view and adding that feature. For example a Button
with click count or an ImageView
with SVG support.
If the view looks complex, contains other views and some logic, then start by designing the layout in the editor and then wrap it in a view extending the root layout. In this article, we will call such views compound views.
If the view is a layout with custom layout params or laying out algorithm but without other features, then the view should extend ViewGroup
. If you need recycling, then start with RecyclerView
.
Android Studio encourages programmers to extend AppCompat versions of basic Android views instead of the original classes. As usual, the choice depends on your needs and goals. If you don't need AppCompat extensions, feel free to ignore that suggestion and stick to the basic Android views. AppCompat views look and behave a lot like third party classes with its custom attributes and tons of helper classes. Without AppCompat your library will be lighter and easier to manage.