views:

28

answers:

2

Its a dumb question. Prepare yourself.

My main.xml is this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent" 
 android:layout_height="fill_parent"
 android:background="@android:color/white">
 <ImageButton
 android:src="@drawable/button"
 android:scaleType="fitStart"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
 /> 
</RelativeLayout>

It works. However, I actually SEE an android button with my image inside it. When you click it, the outside turns orange and everything. How do I get it so that the outside button DOESN'T appear?

Help please?

A: 

There are two possible ways to handle this:

  1. Set the a transparent background to the button.
  2. Use ImageView instead of the Button (you may want to set android:focusable="true" to make it focusable)
Konstantin Burov
Thanks, but an ImageView just won't work... It shows only the first drawable. Why is that?
Mia
Have you specified on click listener for the view? It will not be clickable until do that. Also do not forget to make it focusable.
Konstantin Burov
I can't find a code for that... what do you mean?And I did make it focusable.
Mia
http://developer.android.com/intl/zh-TW/guide/topics/ui/ui-events.htmlhttp://tseng-blog.nge-web.net/blog/2009/02/14/implementing-listeners-in-your-android-java-application/You can pick up examples there.
Konstantin Burov
Also look easier click listeners section on the article http://android-developers.blogspot.com/2009/10/ui-framework-changes-in-android-16.html
Konstantin Burov
A: 

You want to add an onClick listener to an ImageView if you don't actually want a button (and a button does look as you've described).

Sinjo
Do you mean like with the Java? Because I'm using XML...
Mia
Okay, I didn't realise that it was possible to specify the On Click action in the XML (which is good to know). It looks like ImageView has that property too, so you should be able to set it there too.
Sinjo