How do I set the selected state of an image button with xml

Jay Askren picture Jay Askren · Feb 10, 2010 · Viewed 9.8k times · Source

I have an image button as defined below.

<ImageButton 
    android:text="Play"
    android:src="@drawable/playpause"
    android:background="@drawable/opaque" 
    android:gravity="center_horizontal"
    android:id="@+id/player_ctrl_btn"
    android:layout_width="fill_parent" 
    android:padding="0px"
    android:layout_height="wrap_content" />

I want to set the default state of the button to be selected. So in code I would say:

playBtn.setSelected(true);

Is it possible to do this in xml?

Answer

CommonsWare picture CommonsWare · Feb 10, 2010

It doesn't look like you can -- sorry!