I created a button with an image set as the background through a drawable. When I run the program the image is not being centered nor shrunk to fit the button. But when you click it, the pressed image is showing properly. This was working just the other day and I have no clue what happened to change it.
main.xml
<Button
android:id="@+id/rightarrow"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:clickable="false" />
Activity.java
rightarrow = (Button) findViewById(R.id.rightarrow);
rightarrow.setBackgroundResource(R.drawable.rightarrow_drawable);
rightarrow_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/rightarrow_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/rightarrow" />
</selector>
Why not set the selector in XML? You do not have to set it by code.
Try Project->Clean in Eclipse – maybe your resources got mixed.