0

how to use color state list for background? I know android:background="@drawable/drawable_selector", but android:background="@color/color_selector" will cause exceptions. but android:background="#FFFFFF" works again, can anyone explains why?

now i want to change a layout's background color(not a drawable) when it's pressed, how to do it?

Sahil Mahajan Mj
  • 11,033
  • 8
  • 53
  • 100
kwf2030
  • 195
  • 2
  • 13

2 Answers2

0

dynamically you can change like this. Use this if it is useful for you - textView.setBackgroundColor(Color.parseColor(getResources().getString(R.string.red)));

0

put the color in res/values/colors.xml, like #FFFFFF, and then create a drawable xml in drawable directory, ,that is ok.

kwf2030
  • 195
  • 2
  • 13