This tutorial will demonstrate how to create a custom view that will change its appearance based on a custom attribute set in the xml layout.
1. Custom Attributes
If you have used Android Views in the layout editor, you are probably already familiar with setting attributes for views. For example, for an ImageView you can set the drawable attribute to determine what graphic to draw, or the Text Attribute for a button or label to determine what text will display.
If you find yourself designing a custom view, you may want to add custom attributes to that view that affect the display or behavior. For this example we will build off of the custom view that created before, and add an attribute to change the border color.
Showing posts with label custom view. Show all posts
Showing posts with label custom view. Show all posts
Tuesday, May 1, 2012
Friday, March 9, 2012
Creating a Simple Custom Android View
This tutorial will show you how to create an extremely simple custom view that draws a red border, and add this view to a layout.
1. Why Create a Custom View?
You may be wondering why you would ever want to create a custom view. Android comes with many views already, and these views follow behaviors that the user expects and has grown accustomed to (buttons, check boxes, text inputs). These views are fine and work great, but sometimes they do not provide all the functionality that your apps requires, or you may simply wish to build a more customizable component.
1. Why Create a Custom View?
You may be wondering why you would ever want to create a custom view. Android comes with many views already, and these views follow behaviors that the user expects and has grown accustomed to (buttons, check boxes, text inputs). These views are fine and work great, but sometimes they do not provide all the functionality that your apps requires, or you may simply wish to build a more customizable component.
Subscribe to:
Posts (Atom)