Issue
I want to change my button background at RUNTIME
I know how to add a custom background to a button, but
How can I change it to borderlessButtonStyle? in the xml was easy, I used:
style="?android:attr/borderlessButtonStyle")
How can I switch back to the default background? The following is not what I want (apperantly it is not the default used in Jelly Bean)
changeableButton.setBackgroundResource(android.R.drawable.btn_default);
Thanks for your help
Solution
I actually found a solution
You can save the initial background of your button in a Drawable object
Drawable d = button.getBackground();
Now you can modify your button's background as you wish
button.setBackgroundResource(R.drawable.custom_button);
Than you can modify it back
button.setBackgroundDrawable(d);
Answered By - Tünde
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.