Showing posts with label Text. Show all posts
Showing posts with label Text. Show all posts

android:text - Display Text in a TextView/EditText

How to Display Text in a TextView/EditText

android:text was added in API Level 1

Set text to display.

1. Add a TextView in the main.xml file.

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

<TextView
        ...
       android:text = "This text will display."
/>

3. Compile and run!

4. Instead of hard coded text, you can link the text to the string.xml file, as below. Where hello is the name of the string to display.

android:text = "@string/hello"

Next Recommended Article: android:id - How to Name a TextView

Resources:
http://developer.android.com/reference/android/widget/TextView.html#attr_android:text
http://developer.android.com/reference/android/R.atr.html#text


android:textStyle - Bold Text in a Button

How to Bold Text in a Button

added in API Level 1

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

2. Add a Button.

3. Open the layout, main.xml and add the following highlighted code inside the <Button> tag.

<Button
  ...

     android:textStyle="bold"
/>

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"
/>