Showing posts with label Image. Show all posts
Showing posts with label Image. Show all posts

android:clickable - Make an ImageView Clickable

How to Make an ImageView Clickable

android:clickable was added in API Level 1

Defines whether the ImageView reacts to click events.

1. Add an ImageView in your main.xml file.

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

  <ImageView
        ...
       android:clickable = "true"
  />

3. Compile and run!

Resources:
http://developer.android.com/reference/android/view/View.html#attr_android:clickable
http://developer.android.com/reference/android/R.attr.html#clickable

android:background - Set an Image as Background on a TextView, using background

How to Set an Image as Background on a TextView, using background

Note: This will set the background of a TextView to your image. If text, you can still see the text. The image expands the textview to remaining view of the device. It will resize the picture so you can see the whole picture on your device.

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

2. Add a TextView.

3. Add your image to res\drawable directory. 

3. In the main.xml file, add the below line

  <TextView
    ....
      android:background = "@drawable/myImage" 
  />
 
5. Compile and run!

Related Articles



Resources: