Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用颜色状态列表作为背景?我知道android:background="@drawable/drawable_selector",但android:background="@color/color_selector"会导致异常。但android:background="#FFFFFF"再次工作,谁能解释为什么?
android:background="@drawable/drawable_selector"
android:background="@color/color_selector"
android:background="#FFFFFF"
现在我想在按下时更改布局的背景颜色(不是可绘制的),该怎么做?
把颜色放在res/values/colors.xml中,比如#FFFFFF,然后在drawable目录下创建一个drawable xml,就OK了。
动态你可以像这样改变。如果它对您有用,请使用它 - textView.setBackgroundColor(Color.parseColor(getResources().getString(R.string.red)));