android-ui - 关于android控件布局样式的问题
迷茫
迷茫 2017-04-17 12:57:46
0
1
702

初学android没几天,界面设计在网上看范例的时候发现一个问题,为什么有些的控件样式写在drawable/XXX.xml目录里,用@drawable/引用?为什么有的控件样式写在values/style.xml文件里,用@style/引用?有的控件样式甚至两个方法都用上了,这样操作完成一个项目的样式结构岂不是很混乱?

在网上看到还有的源码,用style就可以解决的,他用drawable文件解决,本人不得其解,希望同仁帮忙解答困惑。

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
伊谢尔伦

The style of a control includes many attributes, such as background, foreground (ImageView), appearance animation, disappearing animation, etc.

The files in the drawable folder are defined for a certain attribute. For example, if I want to define a red rounded rectangle background, I will write an xml file with a shape tag in the drawable folder. Then reference

via @drawable

The files in the style folder are defined for a certain type of control (a collection of several properties). There are generally two situations when defining in the style folder

  1. It is necessary to repeatedly define a type of control. For example, if a large number of fade-in and fade-out effects are used in the APP, then the fade-in and fade-out effects will be defined as a style and referenced through @style
  2. You need to modify the styles provided by the system, for example, change the color of Theme.Holo’s ActionBar to red, and leave everything else unchanged
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template