Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get the background color of a button in android
- android:tag="#ff0000"
- String colorCode = (String)btn.getTag();
- Button button = (Button) findViewById(R.id.my_button);
- Drawable buttonBackground = button.getBackground();
- ColorDrawable buttonColor = (ColorDrawable) button.getBackground();
- int colorId = buttonColor.getColor();
- if (colorID == R.color.green) {
- log("color is green");
- }
- public Drawable getBackground();
- public int getColor()
Add Comment
Please, Sign In to add comment