Using custom views with layouts
One of the most important parts is the user interface, as it is the most visible part of an app. When we create apps for Android devices, sometimes we may need to create custom views.
How to do it...
Creating a new UI control involves creating a new type, inheriting either directly or indirectly from one of the View
types. Here's how it's done:
- If we want to create more advanced button control, we must create a new type inheriting from the
Button
type. We also need to ensure that the namespace is user friendly as it will be used in the layout files:namespace XamarinCookbook.Views { public class TimedButton : Button { } }
- Now we can implement the functionality that this button provides:
public int Interval { get; set; ...
Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.