, !
JSON , . Google , / xml. - - R.color.primary_button .
Resources, .
, productFlavors. - (, ) , . , PlayMarket/AppStore. : runtime.
, :
- 47 ;
- ~50 shapes selectors;
- ~70 ( , ).
:
- Activity , UI ( , Views id Activity ).
- UI ( , Activity, xml).
- Resources - , View Shape.
.
. Resources
Android Resources. View Shape . Context.
Google ContextWrapper, . attachBaseContext. .
Resources
, , . , , getColor, View, TypedArray ( ). , . , , , .
TypedValue TypedArray. , Resources .
, Resources getValue. , getColor ( ) getDrawable ( ColoredDraawble).
TypedArray . , private. . , final AssetManager. , , .
. , . TypedValue TypedArray , . , .
Resources. , Android android.support.v7.widget.ResourcesWrapper. - . , ResourcesWrapper .
, :
- View.
- Shape Selector.
O View. LayoutInflater
,
github.com/chrisjenx/Calligraphy. , , LayoutInflater. LayoutInflater ContextWrapper. LayoutInflater , View ( , , ). , View .
Shape
. . C Resources createFromXml, xml , TypedArray. ColorStateList.
( , ). Id , - . . Resources getXml. xml . , Id Resources Drawable .
ColorStateList ( Drawble) . , .
Resources Drawable ColorStateList. .
ColorStateList. , Resources .
ColorDrawable ColorStateList ( ColorStateList , selector). id , , .
:
- LayoutInflater, View.
- Singletone getDrawable(int resId, Resources baseResource), , Drawables ColorStateLists.
- , .
(, ). .
: View, Shapes Selectors . API ( 24) device specific .
, , . runtime .
!
https://habrahabr.ru/post/334010/