Android - How to set and get TextView Background Color Programmatically




Asked on September 15, 2015

How to set and get TextView background color programmatically in Android?




Replied on September 15, 2015

Suppose we have a TextView as

TextView text = (TextView) activity.findViewById(R.id.text);


1. Set Background Color Programmatically


text.setBackgroundColor(Color.LTGRAY);


2. Get Background Color Programmatically


(ColorDrawable)text.getBackground()).getColor();





Replied on September 15, 2015
Thanks for quick response. It's working.

Write Answer










©2024 concretepage.com | Privacy Policy | Contact Us