Showing posts with label Color. Show all posts
Showing posts with label Color. Show all posts

android:scrollbarTrackHorizontal - Set the Color of Horizontal Track of Scrollbar in a TextView


Set the Color of Horizontal Track of Scrollbar in a TextView

android:scrollbarTrackHorizontal was added in API Level 1
Defines the horizontal scrollbar track drawable. By default, it only displays the track when you scroll the view.


1. Create an Android project, if you don't already have one.

2. Add a Horizontal Scrollbar to a TextView

3. Add a Shape Drawable file named thumb01.xml, with the solid color as #FF0000. (This will be red.)

4. In the main.xml file, add the code below.

  <HorizontalScrollView
        ...
        android:scrollbarTrackHorizontal = "@drawable/thumb01"
  />
5. Compile and run!

Related Articles:


Resources:

Add a Shape Drawable

How to Add a Shape Drawable

A Shape Drawable is a generic shape defined in XML.

1. Create an Android project, if you don't already have one.

2. Create an XML file named thumb01.xml in the res/drawable directory.

3. Open the thumb01.xml file and add the following code.

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FF0000"/>
</shape>

4. To add a color for the shape, add the code between the <shape> tags. The below will set the color to red.

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FF0000"/>
</shape>
Related Articles:

Resources:
http://developer.android.com/guide/topics/resources/drawable-resource.html
https://code.google.com/p/android/issues/detail?id=14317

android:textColorLink - Set the Color of Link Text (URLs) in a TextView/EditText

How to Set the Color of Link Text (URLs) in a TextView/EditText

added in API Level 1

Color of link text (URLs)

1. Create an Android project, if you don't already have one.

2. Add Clickable URL link.

3. Open the layout, main.xml and add the following highlighted code.
Highlighted color will be red.

<EditText
     ....
     android:textColorLink="#FF0000"
/>

android:textColorHighlight - Set the Color of Highlighted Text in an EditText

How to Set the Color of Highlighted Text in an EditText

added in API Level 1

Color of highlighted text.

1. Create an Android project, if you don't already have one.

2. Add an EditText.

3. Open the layout, main.xml and add the following highlighted code.
Highlighted color will be red.

<EditText
     ....
     android:textColorHighlight="#FF0000"
/>

android:background - Set the Background Color for a TextView

How to Set the Background Color in a TextView

added in API Level 1

This will change the background color of a TextView. A drawable to use as a background. Can be an image, color, PNG image, 9-patch, XML state list description, etc)

1. Add a TextView.

2. In the main.xml file, add the below line. (black background)

  <TextView
    ....
      android:background = "#000000" 
  />
 
3. Determine the Hex color you would like and update above line.

4. Compile and run!

Related Articles

android:textColor -How to Set the Text Color of a Button

android:textColor was added in API Level 1
Set the Color of text
1. Add a Button.

2. Open the layout, main.xml and add the following highlighted code inside the <Button> tag. This will set the text color to green.

<Button
     ....
    android:textColor="#00CC00"
/>

android:background - Change the Background Color of an EditText

How to Change the Background Color of an EditText


1. Create an Android project, if you don't already have one.

2. Add an EditText.

3. Open the main.xml file and add the following highlighted line of code between the <EditText> tags.

<EditText
....
android:background="#212121"
/>

4. Determine the Hex value for the color you would like and replace the android:background value with your color.

5. Compile and run!


Determine the Hex value for a color

How to Determine the Hex value for a color


Below are some web sites that can help you choose just the right color for your project. 


Quick and Easy color selection: www.html-color-names.com

Get the exact shade you want: www.colorpicker.com

Fun Popular Colors:  http://www.color-hex.com/