Open davidsusu opened 9 years ago
Would be great if you could submit a pull request for that. That would definitely be quicker. Thanks!
I started working on ProgressBar and RatingBar support, and I have a question. Could you summarize (in a few words) the logic of the virtual children styling (PXVirtualStyleable classes)?
A virtual child is a way to allow a definition in the CSS for an inner (usually hidden) value you would like to set on a specific View (or complex view). A lot of the views that Android pre-define already have IDs you can hook to via the CSS directly (like the action_bar
id). However, some are not exposed well, so we need to work around them and provide some sort of a way to set those via the CSS. In those cases the virtual
can come in handy.
I'll try to explain this with an example of what we got built-in already, and that is with the ActionBar
.
Take a look at the way we resister an ActionBar logo
virtual at the PXStyleAdapter
class:
registerStyleAdapter(PXVirtualActionBarLogo.class.getName(), PXVirtualActionBarLogoAdapter.getInstance());
The name logo
is defined in the PXVirtualActionBarLogoAdapter, and this will be the way to set it via the CSS:
action-bar logo { background-image: url(pixate-logo.svg); background-size: 230px 73px; }
Basically, it's pretty rare that you will need to use a virtual, but if you find it useful to have the CSS cleaner, than it's something to consider. In the case of the ActionBar
it was pretty useful, as you can see that setting a logo on it involves a bit more (see PXVirtualActionBarLogoAdapter
, that is actually doing all the work).
You can also find more about the way an ActionBar styling work by looking at the sample project at https://github.com/Pixate/pixate-freestyle-android/tree/master/samples/PixateFreestyleActionBarDemo
Hope that helps, and let me know if you need more info!
Is support for ProgressBar and RatingBar expected in the near future? Should I implement it myself instead of waiting for you? Thanks: David.