Wednesday, 15 October 2014

Android programming tutorials.

Labels.


Labels are the simplest widgets in android programming. They are used adjacent to other widgets such as fields.

Dealing with labels in Xml.
This is achieved by adding a TextView element to the layout with an android.text property to set the value of the label itself.

TextView Properties of relevance to labels.

  • android:typeface: Sets the typeface to use for the label (e.gmonospace)
  • android:textStyle: Indicates that the typeface should be made bold(bold), italic (italic), or bold and italic (bold_italic)
  • android:textSize: Specifies the size of the font, in one of several measures: sp(scaled pixels), dip(density-independent pixels), px(raw pixels), in(inches), mm(millimeters). The recommend approach is to use sp, and this is appended to the size, such as 12sp.
  • android:textColor: Sets the color of the label’s text, in RGB hex format (e.g., #FF0000for red

Basic Xml code to demostrate a label.

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="http://mwangisimon.blogspot.com"
/>



No comments:

Post a Comment