Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to define multiple style files to avoid a single huge one in Android?

I would like to know is there any way to define or use multiple styles files(Multiple, style.xml files) in Android, rather than the single style.xml file which is present in the res folder of the Application Project. As currently I am using a single style file (style.xml). But the size of the style.xml file is huge due to my many customized and self-defined styles.

I had gone through many tutorials and examples, But all those tutorial and example providing sites and even the developer.android.com site shows how to define and use Style but, none of the any site says whether it is possible to Make Multiple style.xml files of the single style.xml file so that the size of the file can be reduced.

Any Help would be Appreciated...

like image 209
Pravinsingh Waghela Avatar asked Apr 08 '16 12:04

Pravinsingh Waghela


2 Answers

You are welcome to have as many resources defining styles as you like, at least within reason. There's probably some file-count limit, but it's at least in the hundreds, and possibly in the low billions.

In res/values/, and res/values-*/ directories, filenames do not matter. We use conventions to put resources in files named after the resource, like styles.xml. That is merely an organization system. You are welcome to have as many files with <style> resources as you want, named whatever you want (so long as they are valid resource filenames).

For example, in your Android SDK, if you go to platforms/android-.../data/res/values/ (for some value of ..., based on your installed SDKs), you will see several files that contain style resources:

  • styles.xml
  • styles_*.xml, such as styles_holo.xml
  • themes.xml
  • themes_*.xml, such as themes_material.xml
like image 63
CommonsWare Avatar answered Nov 15 '22 16:11

CommonsWare


You can have those styles on any file you want, it won't matter as long as your filenames are valid. So. For example you can create a style file just for buttons. Don't worry about the order, the styles on all files will be parsed and applied.

like image 29
Benjamín Molina Avatar answered Nov 15 '22 17:11

Benjamín Molina