Upload
rosanna-lambert
View
214
Download
0
Embed Size (px)
Citation preview
Android Development:Basic Widgets
Richard S. Stansbury2015
Widgets
• Widgets are display elements that compose the layout of the Android application
• Common examples:– Labels– Form elements– Images– Maps– etc.
Widget Configuration Elements
• ID– @+id/<id_value> for first declaration– @id/<id_value> for future declarations– in java you can use:
findViewById(R.id.<id_value>)• Dimensions– layout_width, layout_height
• Possible values: a dimension, wrap_content, match_parent• E.g. <TextView
android:id = “@+id/aLabel”android:layout_width=“wrap_content”android:layout_height=“wrap_content”
Widget: TextView
• Displays a text label– Attributes:• android:typeface -
– See http://developer.android.com/reference/android/graphics/Typeface.html
• android:textStyle – bold, italic, bold_italic• android:textColor – RGB or ARGB• android:text = “@string/<string_id>”
• Let’s look at some real examples in Eclipse…
Widget:Button
• Produces a clickable element• Common attributes:– Many of the same as TextView– android:onclick=“<function_name>”
• States click handler method• Useful for many simple layouts• Not useful for fragments
• Look at example in Eclipse…• Refer to the build task that you had last Friday…
Widget:EditText
• Permits text entry• http://developer.android.com/reference/andr
oid/widget/EditText.html
• Attributes– Many same as TextView– android:inputType– android:hint– android:autotext