Pixate Freestyle is a free framework that lets you style your native Android views with stylesheets.
Under the hood, Pixate is a powerful resolution-independent graphics engine which translates familiar CSS markup to scalable graphics and bitmap effects. It is designed to work with your existing assets, as well as with SVG (Scalable Vector Graphics) assets that can be applied to your views just like any other image.
We've tried to make Pixate easy to integrate into any existing app, and there are a few simple steps that need to be done in order to have it integrated with your project.
Initialize Pixate in your Activity or Fragment by making a call to Pixate.init(...). For example:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initialize pixate for the Activity
PixateFreestyle.init(this);
// In case it's a Fragment, use:
// PixateFreestyle.init(getActivity());
setContentView(R.layout.main);
}
Pixate enables you to style all Views of the same type by using the View's class name as an element name in the CSS, such as in this example:
Button {
background-color: red;
}
However, in most cases you would style a view by its ID (the same one that was defined in the XML layout):
#myButton {
background-color: red;
}
The above example is a very simple one. Pixate also supports advanced styling instructions, like nth-child for Lists, matrix transformations and more.
See the Views Demo blog post to get a taste of what's possible.
The Pixate Freestyle library is a work in progress. At the moment there are a few common views that we've added extensive support to:
You can find a few sample projects under this repo's Samples folder. These projects use Pixate Freestyle to style various components, and demonstrate the current capabilities of the framework.