{"id":165787,"date":"2013-01-14T17:20:03","date_gmt":"2013-01-14T13:20:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=165787"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=165787","title":{"rendered":"<span class=\"post_title\">\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u043a\u0438\u043d\u043e\u0432 \u0432 Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438\u043b\u0438 \u0441\u043c\u0435\u043d\u0430 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0433\u0430\u043c\u043c\u044b \u0432 \u043e\u0434\u0438\u043d \u043a\u043b\u0438\u043a<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0441\u0435\u0445 \u0445\u0430\u0431\u0440\u0430\u0432\u0447\u0430\u043d!<\/p>\n<p>  \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u0440\u0435\u0448\u0438\u043b\u0430 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u0441 \u0432\u0430\u043c\u0438. <br \/>  \u0417\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u0441\u043c\u0435\u043d\u0430 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0433\u0430\u043c\u043c\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043b\u0438\u043a\u0443. \u0422\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043a\u0438\u043d\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h5>\u0417\u0430\u0434\u0430\u0447\u0430<\/h5>\n<p>   C\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0432\u0441\u0435 \u0432\u044c\u044e\u0448\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043c\u0435\u043d\u0443 \u0441\u043a\u0438\u043d\u043e\u0432. <\/p>\n<h5>\u0418\u0434\u0435\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f <\/h5>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0430\u043a\u0442\u0438\u0432\u0438\u0442\u0438, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0430\u0440\u0441\u0438\u0442 xml-\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u0435\u0440\u0433\u0430\u0435\u0442 \u043e\u0432\u0435\u0440\u0440\u0430\u0439\u0434 \u043c\u0435\u0442\u043e\u0434 getResources(), \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438\u0437 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438. \u0412\u043e\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e \u0437\u0432\u0435\u043d\u043e \u043c\u044b \u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u043c\u0435\u0448\u0430\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u0434\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0441\u0432\u043e\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0430 \u043d\u0435 \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0432 \u043f\u043e\u0434\u0432\u043e\u0445\u0430, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043a \u0432\u044c\u044e\u0448\u043a\u0430\u043c. \u0410 \u044d\u0442\u043e \u0442\u043e, \u0447\u0435\u0433\u043e \u043c\u044b, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u0434\u043e\u0431\u0438\u0432\u0430\u043b\u0438\u0441\u044c. <\/p>\n<h5>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0434\u0435\u0438<\/h5>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e:<\/p>\n<p>  1) \u0432 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u044b (\u0442.\u0435. \u043d\u0435\u044f\u0432\u043d\u043e). \u041d\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0432\u0441\u0451 \u0447\u0435\u0440\u0435\u0437 drawable \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0446\u0432\u0435\u0442\u0430 <\/p>\n<pre><code class=\"xml\">android:background=&quot;@color\/color_tabbar_background&quot; <\/code><\/pre>\n<p>  2) \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 BasicActivity, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 Activity \u0438 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0430\u043a\u0442\u0438\u0432\u0438\u0442\u0438 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u043d\u0435\u043c \u043c\u0435\u0442\u043e\u0434 getResources().<\/p>\n<p>  3) \u0422\u0430\u043a \u0436\u0435, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e ResourseManager, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 Resourses. <\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 getResources() \u0432 \u0430\u043a\u0442\u0438\u0432\u0438\u0442\u0438. \u0412\u043e\u0442 \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <a href=\"http:\/\/developer.android.com\/reference\/android\/content\/Context.html#getResources()\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a <\/a>. \u0422.\u0435. \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 Resources, \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 BasicActivity \u0432 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 getResources() \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u0442\u0435\u043c\u0430 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0430 \u043b\u0438 \u043e\u043d\u0430 \u0432\u043e\u043e\u0431\u0449\u0435, \u0435\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0432\u043e\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 ResourseManager. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u0434\u043b\u044f \u044f\u0441\u043d\u043e\u0441\u0442\u0438<\/p>\n<pre><code class=\"java\">public class BasicActivity extends Activity {     private ResourceManager manager = null;     @Override     public Resources getResources() {         if (App.checkCurrentSkin()) {             if (manager == null) {                 manager = new ResourceManager(super.getResources());             }             return manager;         } else             return super.getResources();     } } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0430\u043a\u0442\u0438\u0432\u0438\u0442\u0438.<br \/>   \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043d\u0430\u0448\u0435\u043c\u0443 ResourseManager. \u0412 \u043d\u0435\u043c \u043d\u0430\u043c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u0435\u043d \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b getColor(int id) loadDrawable(TypedValue value, int id), getColorStateList(int id). \u0421 \u0434\u0432\u0443\u043c\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0443 \u043d\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u2014 \u043e\u043d\u0438 \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0435. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0438\u043c \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442. \u041d\u043e \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f \u043a \u043d\u0430\u043c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 <a href=\"http:\/\/habrahabr.ru\/post\/69552\/\">JAVA Reflection<\/a>! \u041a\u0430\u043a \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f \u0441\u0430\u043c\u0438, \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0443, \u0442.\u043a. \u044d\u0442\u043e \u043d\u0435 \u0442\u0435\u043c\u0430 \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0432\u0430\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f  <\/p>\n<pre><code class=\"java\">public class ResourceManager extends Resources {     Skin mSkin = App.getCurrentSkin();     Method loadDrawable;     Method loadColorStateList; Resources mBaseResources;      public ResourceManager(Resources baseResources) {         super(baseResources.getAssets(), baseResources.getDisplayMetrics(), baseResources.getConfiguration());         mBaseResources = baseResources;        Method[] methods = Resources.class.getDeclaredMethods();         for (Method method : methods) {             if (method.getName().equals(&quot;loadDrawable&quot;)) {                 loadDrawable = method;                 loadDrawable.setAccessible(true);             } else if (method.getName().equals(&quot;loadColorStateList&quot;)) {                 loadColorStateList = method;                 loadColorStateList.setAccessible(true);             }         }     } <\/code><\/pre>\n<p>  \u0422.\u043e. \u043c\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u044b\u0445 \u043d\u0430\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0435\u043b\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430 \u043c\u0430\u043b\u044b\u043c, \u0432 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u043f\u043e \u0435\u0433\u043e \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a\u0443 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439. \u0412 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432\u044b \u043a\u0430\u043a \u0443\u0433\u043e\u0434\u043d\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 Skin, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u043e\u043b\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u0430\u0448\u0438\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0432\u044c\u044e\u0448\u043a\u0430\u043c \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0438\u0445 \u0446\u0432\u0435\u0442\u043e\u0432. \u0412\u043e\u0442 \u0432\u0430\u043c \u043a\u0443\u0441\u043e\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432  <\/p>\n<pre><code class=\"java\">@Override     public int getColor(int id) throws NotFoundException {         String color;         switch (id) {             case R.color.chat_in:                 color = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_RECEIVE_MESSAGE_BUBLE).getBackgroundColor();      \/\/ \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u043d\u0430\u0447\u0430\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 #b7c0c7                 return Color.parseColor(color);             case R.color.chat_send:                 color = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_SEND_MESSAGE_BUBLE).getBackgroundColor();                 return Color.parseColor(color); \u2026. <\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434  <\/p>\n<pre><code class=\"java\">public Drawable loadDrawable(TypedValue value, int id) {         Drawable d = null;         String color;         String colorSel;         GradientDrawable result;         switch (value.resourceId) {             case R.color.color_background_main:                 color = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_VIEW).getBackgroundColor();                 return new ColorDrawable(Color.parseColor(color));  case R.drawable.button_blue_selector:                 color = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_BUTTON_BLUE).getBackgroundColor();                 colorSel = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_BUTTON_BLUE).getHighlightedBackgroundColor();                 return createSelector(Color.parseColor(color), getDarkerColor(color), colorSel); case R.drawable.chat_in:                 color = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_RECEIVE_MESSAGE_BUBLE).getBackgroundColor();                 result = new GradientDrawable(Orientation.TOP_BOTTOM, new int[]{Color.parseColor(color),                         Color.parseColor(color)});                 result.setCornerRadius(25);                 return result; case R.drawable.list_view_selector:                 colorSel = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_TABLE_VIEW_CELL)                         .getHighlightedBackgroundColor();                 ColorDrawable drawable = new ColorDrawable(Color.parseColor(colorSel));                 StateListDrawable listDrawable = new StateListDrawable();                 listDrawable.addState(new int[]{android.R.attr.state_pressed}, drawable);                 return listDrawable; case R.drawable.button_last_menu_selector:                 color = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_TABLE_VIEW_CELL).getBackgroundColor();                 colorSel = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_TABLE_VIEW_CELL)                         .getHighlightedBackgroundColor();                 return createSelectorForDifferentCorers(Color.parseColor(color), getDarkerColor(color), colorSel, 0, 0, 15,                         15); default:                 break;         }          try {             d = (Drawable) loadDrawable.invoke(mBaseResources, value, id);         } catch (IllegalArgumentException e) {             e.printStackTrace();         } catch (IllegalAccessException e) {             e.printStackTrace();         } catch (InvocationTargetException e) {             e.printStackTrace();         }          return d;     } <\/code><\/pre>\n<p>  \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439  <\/p>\n<pre><code class=\"java\">@Override     public ColorStateList getColorStateList(int id) throws NotFoundException {         String color;         String colorSel;         ColorStateList res;         switch (id) {             case R.drawable.tab_text_selector:                 color = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_TABBAR_ITEM).getTextColor();                 colorSel = mSkin.getControlWithType(SkinConstants.SKIN_CONTROL_TABBAR_ITEM).getHighlightedTextColor();                 res = new ColorStateList(new int[][]{new int[]{android.R.attr.state_selected},                         new int[]{-android.R.attr.state_selected}}, new int[]{Color.parseColor(colorSel),                         Color.parseColor(color)});                 return res;             default:                 break;         }         return super.getColorStateList(id);     } <\/code><\/pre>\n<p>  \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0432\u0441\u0435 drawabl`\u044b. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443<\/p>\n<pre><code class=\"java\">private Drawable createSelectorForDifferentCorers(int startColor, int endColor, String colorSel, float topLeft,                                                       float topRight, float bottomRight, float bottomLeft) {         StateListDrawable drawable = new StateListDrawable();         GradientDrawable gradientDrawable1 = new GradientDrawable(Orientation.TOP_BOTTOM, new int[]{startColor,                 endColor});         GradientDrawable gradientDrawable2 = new GradientDrawable(Orientation.TOP_BOTTOM, new int[]{                 Color.parseColor(colorSel), getDarkerColor(colorSel)});          gradientDrawable1.setShape(GradientDrawable.RECTANGLE);         gradientDrawable1.setCornerRadii(new float[]{topLeft, topLeft, topRight, topRight, bottomRight, bottomRight,                 bottomLeft, bottomLeft});         gradientDrawable1.setStroke(1, endColor);          gradientDrawable2.setShape(GradientDrawable.RECTANGLE);         gradientDrawable2.setCornerRadii(new float[]{topLeft, topLeft, topRight, topRight, bottomRight, bottomRight,                 bottomLeft, bottomLeft});         gradientDrawable2.setStroke(1, endColor);          drawable.addState(new int[]{android.R.attr.state_pressed}, gradientDrawable2);         drawable.addState(new int[]{android.R.attr.state_checked}, gradientDrawable2);         drawable.addState(new int[]{-android.R.attr.state_selected}, gradientDrawable1);         return drawable;     } <\/code><\/pre>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c, \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u043f\u043e\u043b\u0451\u0442 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0438. <br \/>  \u0415\u0449\u0451 \u0445\u043e\u0447\u0443 \u0441\u0440\u0430\u0437\u0443 \u043e\u0431\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u043d\u0435 \u043e\u0442\u0440\u0438\u0441\u0443\u0435\u0448\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u043a\u043e\u043d\u043a\u0430 \u0434\u043b\u044f \u0442\u0430\u0431\u0430, \u0442\u043e \u0441\u043c\u0435\u043d\u0443 \u0435\u0451 \u0446\u0432\u0435\u0442\u0430 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0438\u043a\u043e\u043d\u043a\u0438 \u0431\u044b\u043b\u0430 \u0447\u0438\u0441\u0442\u043e \u0431\u0435\u043b\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0435\u0451 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u043d\u0430\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u043f\u0443\u0442\u0451\u043c \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0446\u0432\u0435\u0442\u043e\u0432. \u0412\u043e\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c \u0446\u0432\u0435\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438  <\/p>\n<pre><code class=\"java\">Drawable example = ImageManager.blendColorDrawable(this, R.drawable.arrow, R.color.color_2_end);  <\/code><\/pre>\n<p>  \u0438 \u043c\u043e\u0436\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043d\u0435\u0439, \u0432\u0441\u0451, \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e. \u0425\u043e\u0442\u044c \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u043a\u043e\u043d\u043a\u043e\u0439 \u043d\u0430 \u0442\u0430\u0431.   <\/p>\n<pre><code class=\"java\">public static Drawable blendColorDrawable(Context context, int baseId, int colorId) {          Resources res = context.getResources();         BitmapFactory.Options options = new BitmapFactory.Options();         options.inPreferredConfig = Bitmap.Config.ARGB_8888;         Bitmap base = BitmapFactory.decodeResource(res, baseId, options);          Bitmap blend = Bitmap.createBitmap(base.getWidth(), base.getHeight(), Config.ARGB_8888);         blend.eraseColor(context.getResources().getColor(colorId));          Bitmap result = base.copy(Config.ARGB_8888, true);         Paint p = new Paint();         p.setXfermode(new PorterDuffXfermode(Mode.MULTIPLY));         p.setShader(new BitmapShader(blend, TileMode.CLAMP, TileMode.CLAMP));          Canvas c = new Canvas();         c.setBitmap(result);         c.drawBitmap(base, 0, 0, null);         c.drawRect(0, 0, base.getWidth(), base.getHeight(), p);          return new BitmapDrawable(context.getResources(), result); <\/code><\/pre>\n<p>  \u0422.\u043a. \u044f \u0432\u044b\u0431\u0438\u0440\u0430\u043b\u0430 \u043a\u0443\u0441\u043a\u0438 \u0438\u0437 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0433\u0434\u0435 \u044d\u0442\u043e \u0432\u0441\u0451\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0430 \u0438\u0437 \u0444\u0438\u0447, \u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0435 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u044e. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u0442\u0435\u0441\u044c \u0438 \u043e\u0447\u0435\u043d\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u043e, \u043c\u043e\u0433\u0443 \u043d\u0430\u043a\u0438\u0434\u0430\u0442\u044c \u0432\u0430\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0447\u0438\u043a \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u041f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445! \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/165787\/\"> http:\/\/habrahabr.ru\/post\/165787\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e \u0432\u0441\u0435\u0445 \u0445\u0430\u0431\u0440\u0430\u0432\u0447\u0430\u043d!<\/p>\n<p>  \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u0430\u043d\u0434\u0440\u043e\u0438\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u0440\u0435\u0448\u0438\u043b\u0430 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u0441 \u0432\u0430\u043c\u0438. <br \/>  \u0417\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u0441\u043c\u0435\u043d\u0430 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0433\u0430\u043c\u043c\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043b\u0438\u043a\u0443. \u0422\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043a\u0438\u043d\u043e\u0432 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-165787","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=165787"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/165787\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}