Home > Android > Setting the background image of an Android TextView

Setting the background image of an Android TextView

TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; see for a subclass that configures the text view for editing.
In most cases u want add image as textView background. It’s so easy. In layout xml file u must write:

android:text="A normal PNG file (*.png) 
will be loaded with an empty one-pixel border added around the image, 
in which you can draw the stretchable patches and content area. 
A previously saved 9-patch file (*.9.png) will be loaded as-is, 
with no drawing area added, because it already exists."

Then u will see result as following:

Of course u want see text in bubble 🙂 For this u must edit image with 9patch
Then save image as 9.png and add to project drawable folder. Save project and run again if everything goes ok u must see result as following:
If u find this post useful then don’t forget leavecomment 🙂
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: