-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] Runtime

, 24 2017 . 17:23 +
, !

JSON , . Google , / xml. - - R.color.primary_button .

Resources, .


, productFlavors. - (, ) , . , PlayMarket/AppStore. : runtime.

, :

  • 47 ;
  • ~50 shapes selectors;
  • ~70 ( , ).

:

  1. Activity , UI ( , Views id Activity ).
  2. UI ( , Activity, xml).
  3. 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 .


, :

  1. View.
  2. 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 , , .


:

  1. LayoutInflater, View.
  2. Singletone getDrawable(int resId, Resources baseResource), , Drawables ColorStateLists.
  3. , .

(, ). .

: View, Shapes Selectors . API ( 24) device specific .

, , . runtime .

!
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/334010/

:  

: [1] []
 

:
: 

: ( )

:

  URL