Styles and themes on Android allow you to separate the details of your app design from the UI structure and behavior, similar to stylesheets in web design.
Android上的style和theme允许你将应用中设计的详细细节与UI结构和行为进行分离,类似于web设计中的样式表。
A style is a collection of attributes that specify the appearance for a single View. A style can specify attributes such as font color, font size, background color, and much more.
Style是一些可以指定单个View外观的属性集合,一个style可以指定一些属性比如字体颜色,字体大小,背景颜色等等。
A theme is a type of style that’s applied to an entire app, activity, or view hierarchy—not just an individual view. When you apply your style as a theme, every view in the app or activity applies each style attribute that it supports. Themes can also apply styles to non-view elements, such as the status bar and window background.
Theme是一种应用于整个app,activity或者view层次的style,而不仅仅是单独的view。当你应用你的style作为theme时,每一个app或者activity中的view将应用它支持的每个style属性。theme还可以将style应用于非view元素,例如状态栏和窗口背景。
Style和theme定义在res/values/文件夹下,通常命名为styles.xml(也可以根据需求命名为其他文件名)。
打开res/values/styles.xml文件