I want my Android button to have some properties:
- Have Android HoloLight style
- Behave as an ImageButton - have an image as its content, not text
- Behave as a ToggleButton - toggle on/off status
So my codes currently look something like these:
My xml file:
<ImageButton
android:id="@+id/button"
style="@android:style/Widget.Holo.Light.Button.Toggle"
android:layout_width="70px"
android:layout_height="70px"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="5dp"
android:src="@drawable/icon" />
My java file:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_file);
Button button = (ImageButton) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.v(log, "button pressed");
if (skillsButton.isSelected()) {
Log.v(log, "button is unselected");
button.setSelected(false);
} else {
Log.v(log, "button is selected");
button.setSelected(true);
}
}
});
}
As I run my code and click the button, I can see that my button has an image as its description, and looks like an Android HoloLight ToggleButton, but it does not turn on and off as I pressed it (the blue light does not turn on).
I can see that the isSelected() status of the button is changing on LogCat though.
Is there a solution to what I want?
Also, as far as I have tried, the "color" of an Android HoloLight themed button is fixed to light gray. Is there a way to change this color to another one, preferably white?