Color




The Color class has many predefined color constants and allows you to create your own color objects.

Example:

<TextView
   android:id="@+id/swimmernameid"
   android:background="#ff99ff"
   android:text="Doe, Susan"
   android:textStyle="bold"    android:textSize="20sp"
   android:singleLine="true"
/>


// You can declare a reference variable to the TextView in code.
private TextView swimmerNameView;


// You can get a reference to it by calling findViewById.
// You usually do this in the onCreate method.
swimmerNameView = (TextView) findViewById(R.id.swimmernameid);


swimmerNameView.setTextColor(Color.Black); swimmerNameView.setText("Swimmer Name");
int color = 0x30FF9966;
swimmerNameView.setBackgroundColor(color);


Color myColor = new Color(red, green, blue);

Where red is an integer between 0 and 255
Where green is an integer between 0 and 255
Where blue is an integer between 0 and 255