{"id":281104,"date":"2016-11-17T11:05:04","date_gmt":"2016-11-17T08:05:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=281104"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=281104","title":{"rendered":"\u0428\u0440\u0438\u0444\u0442\u044b \u0434\u043b\u044f Android"},"content":{"rendered":"<p>\u0414\u0435\u043d\u044c \u0434\u043e\u0431\u0440\u044b\u0439! \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043a\u0430\u043a \u0448\u0440\u0438\u0444\u0442\u044b \u0432 Android. \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 TextView \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0448\u0440\u0438\u0444\u0442\u044b \u0432 xml \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0438\u0445 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0432 \u043f\u0440\u0435\u0432\u044c\u044e. \u0422\u0430\u043a \u0436\u0435 \u0440\u0435\u0448\u0438\u043c \u043e\u0434\u043d\u0443 \u0432\u0430\u0436\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0440\u0438\u0444\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u0431\u0435\u0437 \u0433\u043b\u044e\u043a\u043e\u0432 \u0438 \u043d\u0430\u043f\u0440\u044f\u0433\u043e\u0432 \u0434\u043b\u044f \u0431\u0440\u0430\u0442\u044c\u0435\u0432 \u043d\u0430\u0448\u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0438\u0445, \u043d\u0430\u0448\u0438\u0445 Android-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u0430\u043b\u044c\u0448\u0435 \u044f \u0440\u0430\u0441\u043f\u0438\u0448\u0443 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443 assets \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u0448\u0440\u0438\u0444\u0442\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0430\u043f\u043a\u0438 assets \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0448\u0440\u0438\u0444\u0442\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0430\u043f\u043a\u0430 assets \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0448\u0440\u0438\u0444\u0442\u043e\u0432. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0432 \u043a\u043e\u0440\u043d\u0435 main:<br \/>  \\app\\src\\main\\assets<br \/>  \u041b\u0438\u0431\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c <br \/>  <img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/81J_Hp12769jpPVhaj0ZRt5JRDA_8KxeeVN_kmNQkmgG3ToNq4EwinhOOuukNOBkVWKNHE6Ri6y4zDB3NZXHAQH2TsoHjnUGRSFujtIDSJqYqHB3ujR48AomyjZPwC7WX4gKlFCcyNnuq9Z6tNufrv1IO5dtR-Wkfs2iHrLLAKaHrU3rLiFKzWi2HmbKFQ1nYVyAYk1eRHObX8gcoOt0rrL20GaQqW77nDCf8R2LvjjSIbhEMCYlweCdT8fBQ7ntkW_P4oM0eUh7VcvwV7qjvCCKdggkAYtFHBIuB_Ss4KlU_0EVDydk-omQ59Ef8MDDnA2ZDN6nJ5R0wK-vdO7b2K04pMVv8TD6IfnnuQFx-fapdN_fx31Pj81JYKUZuAfoocUm0HQbpjVwPIvE_4CwDWa-UOzXnf0WJQs76l1cuI9mZfX2-GVFJ510TfW5BHkO7Oxmq8rtoxzh6JFQJVdM7ichnCJ3LBajmN_SNuEf51VELzwtvPW5D25f31lMX31TvyCuvb8xQmweVao18ARmdf3fiV7QSEyclMeF1Tao-tMDkfgD8HQB517yfDTEozhM-CMg-KMuZMLL-THp7jVycSeV-Kvpn3VpErNfxlZ08Cpsiao=w803-h602-no\" alt=\"image\"\/><br \/>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0444\u0430\u0439\u043b\u044b \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c .ttf \u0437\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u0432 assets \u043b\u0438\u0431\u043e \u0432 \u043a\u043e\u0440\u0435\u043d\u044c, \u043b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 fonts, \u0442\u0430\u043a \u043a\u0430\u043a assets \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c.   <\/div>\n<\/div>\n<p>  \u0418\u0442\u0430\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0448\u0440\u0438\u0444\u0442\u043e\u0432 \u0434\u043b\u044f TextView, \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"java\">  Typeface type = Typeface.createFromAsset(getAssets(),&quot;fonts\/font1.ttf&quot;);    myTextView.setTypeface(type); <\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043f\u044f\u0442\u0438 TextView, \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0442\u044c. \u041d\u043e \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0430\u043c\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0444\u0430\u0439\u043b\u0430 \u0448\u0440\u0438\u0444\u0442\u0430 \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 Typeface \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432 \u043b\u0438\u0441\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043d\u0435\u0438\u043c\u043e\u0432\u0435\u0440\u043d\u044b\u0435 \u0433\u043b\u044e\u043a\u0438. <\/p>\n<p>  \u0414\u0430\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0435\u0448\u0438\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0441\u0438\u043d\u0433\u0442\u043e\u043d\u043e\u043c. \u0418 \u0442\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435:<\/p>\n<pre><code class=\"java\">   public class SingletonFonts {     private static Typeface font1;     private static Typeface font2;     private static Typeface font3;      public Typeface getFont1() {         return font1;     }      public  Typeface getFont2() {         return font2;     }      public Typeface getFont3() {         return font3;     }       public static void setFont1(Typeface font1) {         SingletonFonts.font1 = font1;     }      public static void setFont2(Typeface font2) {         SingletonFonts.font2 = font2;     }      public static void setFont3(Typeface font3) {         SingletonFonts.font3 = font3;     }      private static volatile SingletonFonts instance;      private SingletonFonts() {}      public static SingletonFonts getInstance(Context activity) {         SingletonFonts localInstance = instance;         if (localInstance == null) {             synchronized (SingletonFonts.class) {                 localInstance = instance;                 if (localInstance == null) {                     instance = localInstance = new SingletonFonts();                 }             }             setFont1(Typeface.createFromAsset(activity.getAssets(), &quot;fonts\/font1.ttf&quot;));             setFont2(Typeface.createFromAsset(activity.getAssets(), &quot;fonts\/font2.ttf&quot;));             setFont3(Typeface.createFromAsset(activity.getAssets(), &quot;fonts\/font3.ttf&quot;));          }         return localInstance;     }   }<\/code><\/pre>\n<p>  \u0418 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0448\u0440\u0438\u0444\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d, \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">public class MainActivity extends AppCompatActivity {     TextView textView1;     TextView textView2;     TextView textView3;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         textView1 = (TextView) findViewById(R.id.text_view_1);         textView2 = (TextView) findViewById(R.id.text_view_2);         textView3 = (TextView) findViewById(R.id.text_view_3);          textView1.setTypeface(SingletonFonts.getInstance(this).getFont1());         textView2.setTypeface(SingletonFonts.getInstance(this).getFont2());         textView3.setTypeface(SingletonFonts.getInstance(this).getFont3());      } } <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0430\u043d\u043d\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u0432\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u043b\u0430\u0433\u043e\u0432 \u0432 \u043b\u0438\u0441\u0442\u0435, \u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0432\u0443\u044e, \u0441\u0430\u043c\u0443\u044e \u0432\u0430\u0436\u043d\u0443\u044e, \u0432\u0430\u043c \u0432\u0441\u0435 \u0442\u0430\u043a \u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f \u0438 \u043d\u0430 \u0432\u0441\u0435 \u0441\u043d\u043e\u0432\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430 \u0441\u0435\u0442\u0438\u0442\u044c \u0448\u0440\u0438\u0444\u0442\u044b, \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0442\u0435\u0440\u044f\u0442\u044c \u043d\u0435\u0440\u0432\u043d\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438. \u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u043f\u0440\u0438\u0432\u044c\u044e \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0448\u0440\u0438\u0444\u0442, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0448\u0438\u0440\u0438\u043d\u0443, \u0432\u044b\u0441\u043e\u0442\u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u0448\u0440\u0438\u0444\u0442\u0430. \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0436\u0438\u0432\u043e\u043c \u0434\u0435\u0432\u0430\u0439\u0441\u0435 \u0438\u043b\u0438 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e. <\/p>\n<p>  \u0412\u0432\u0435\u0434\u0443 \u0432\u044b\u0448\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 TextView \u0441 \u0431\u043b\u044d\u043a\u0434\u0436\u0435\u043a\u043e\u043c \u0438 \u0448\u0440\u0438\u0444\u0442\u0430\u043c\u0438.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e TextView \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u043c\u0438:<\/p>\n<pre><code class=\"java\">public class CustomFontsTextView extends TextView {     public CustomFontsTextView(Context context) {         super(context);     }      public CustomFontsTextView(Context context, AttributeSet attrs) {         super(context, attrs);     }      public CustomFontsTextView(Context context, AttributeSet attrs, int defStyleAttr) {         super(context, attrs, defStyleAttr);     }      public CustomFontsTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {         super(context, attrs, defStyleAttr, defStyleRes);     }  } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0432 \u043f\u0430\u043f\u043a\u0435 values \u0444\u0430\u0439\u043b attrs.xml<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 attrs.xml<\/b><\/p>\n<div class=\"spoiler_text\">\u0418\u0434\u0435\u043c \u0432\u043e\u0442 \u0441\u044e\u0434\u0430<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/Jds1uhJ85a_TGtAuAMPhFcEFkEJFE7GPvYuwpGlq14RLXVYGsXT0TypTJidltPyJwUFOW3XUmYgZxahxBNcf3Gtp5BqBAzfxONEl07k3wugXFKJ5pXxHD7qyHCi0ObeZ_cs_infLRGXA7VyorxCEKvQk36u3cCLaRc0obYYzkWPEmPGnNFiFLRIu_3xQr9_5EhxlgzASZ22AbigYuO22aDIfvt3valT-n9AX41Iqb4oJ8Yyh2EN4beR2yUm9e4yFBh2OAz6NarRQ7RrwmDg2RTVzWIn7qjj27JQSJfgrik5Xw70dkM3SwmXkV3AqizBT6qrZmaViF0IWUira7U6IIpKdv9cu7dtRsutOWmbDbLDtbr79rKHVOmVsVDkG0KiLpcQSpFgd-W4qiKrNXEoqhGc9UIwsefxqFj3uUicW7c0vqVkfzTLt_0Oc3BJzufgAhPD6tojKjdWjGU3RdT_xuwGUzF8CdEu1NDyJTKmXlG0XtJHcxMfWFkGeEjZtHFWeZFHKJAeaERXONmQwAPXBq3xhfoB8qB8r9bOVJHZ_CIEQB2pctC8SldrSG2BMHSniig1M__3bRaINnfNliQyR0ThH4AxbCJieRhcRqrKHHA2hI6Y=w669-h575-no\" alt=\"image\"\/><\/p>\n<p>  \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c attrs.xml, \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;resources&gt;      &lt;\/resources&gt; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u043d\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"xml\">  \/\/\u0438\u043c\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430      &lt;declare-styleable name=&quot;CustomFontsTextView&quot;&gt;         \/\/ \u043f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u0432\u0441\u0435\u0445 \u0432\u0430\u0448\u0438\u0445 \u0448\u0440\u0438\u0444\u0442\u043e\u0432. name = &quot;fonts&quot; - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 xml \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430         &lt;attr name=&quot;fonts&quot; format=&quot;enum&quot;&gt;             &lt;enum name=&quot;font1&quot; value=&quot;0&quot;\/&gt;             &lt;enum name=&quot;font2&quot; value=&quot;1&quot;\/&gt;             &lt;enum name=&quot;font3&quot; value=&quot;2&quot;\/&gt;         &lt;\/attr&gt;     &lt;\/declare-styleable&gt;<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0432 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 <b>CustomFontsTextView<\/b> \u0438 \u043f\u0438\u0448\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"java\">   public class CustomFontsTextView extends TextView {     public CustomFontsTextView(Context context) {         super(context);     }      public CustomFontsTextView(Context context, AttributeSet attrs) {         super(context, attrs);         setFonts(attrs,context);     }      public CustomFontsTextView(Context context, AttributeSet attrs, int defStyleAttr) {         super(context, attrs, defStyleAttr);         setFonts(attrs,context);     }      public CustomFontsTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {         super(context, attrs, defStyleAttr, defStyleRes);         setFonts(attrs,context);     }       private void setFonts(AttributeSet attributeSet, Context context){         TypedArray a = context.getTheme().obtainStyledAttributes(                 attributeSet,                 R.styleable.CustomFontsTextView,                 0, 0);         int fonts = a.getInt(R.styleable.CustomFontsTextView_fonts,-1);         SingletonFonts singltonFonts = SingletonFonts.getInstance(context);         switch (fonts){             case (0):                 setTypeface(singltonFonts.getFont1());                 break;             case (1):                 setTypeface(singltonFonts.getFont2());                 break;             case (2):                 setTypeface(singltonFonts.getFont3());                 break;         }     } } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0432\u0441\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u043b\u0434\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442, \u0447\u0442\u043e\u0431\u044b \u0443 \u0432\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u0432 xml \u0444\u0430\u0439\u043b \u043d\u0430\u0448\u0435\u0439 \u0430\u043a\u0442\u0438\u0432\u0438\u0442\u0438 \u0438 \u043f\u0438\u0448\u0435\u043c:<\/p>\n<pre><code class=\"java\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;     xmlns:tools=&quot;http:\/\/schemas.android.com\/tools&quot;     xmlns:app=&quot;http:\/\/schemas.android.com\/apk\/res-auto&quot;     android:id=&quot;@+id\/activity_main&quot;     android:layout_width=&quot;match_parent&quot;     android:layout_height=&quot;match_parent&quot;     android:orientation=&quot;vertical&quot;     tools:context=&quot;library.draw.myapplication.MainActivity&quot;&gt;      &lt;library.draw.myapplication.CustomFontsTextView         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;         android:layout_gravity=&quot;center_horizontal&quot;         android:layout_margin=&quot;16dp&quot;         app:fonts=&quot;font1&quot;         android:textSize=&quot;24sp&quot;         android:id=&quot;@+id\/text_view_1&quot;         android:text=&quot;Hello World!&quot; \/&gt;     &lt;library.draw.myapplication.CustomFontsTextView         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;         android:layout_gravity=&quot;center_horizontal&quot;         android:layout_margin=&quot;16dp&quot;         android:textSize=&quot;48sp&quot;         app:fonts=&quot;font2&quot;         android:id=&quot;@+id\/text_view_2&quot;         android:text=&quot;Hello World!&quot; \/&gt;     &lt;library.draw.myapplication.CustomFontsTextView         android:layout_width=&quot;wrap_content&quot;         android:layout_height=&quot;wrap_content&quot;         android:layout_gravity=&quot;center_horizontal&quot;         android:layout_margin=&quot;16dp&quot;         android:textSize=&quot;24sp&quot;         app:fonts=&quot;font3&quot;         android:id=&quot;@+id\/text_view_3&quot;         android:text=&quot;Hello World!&quot; \/&gt;  &lt;\/LinearLayout&gt; <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u0432\u044c\u044e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0443\u0436\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0448\u0440\u0438\u0444\u0442\u0430\u043c\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/4CByEWOJTQkGtRvaymqcj7nP0-CoYSuY-NWZY1S_NiKELiEkBf_zgdQLjlchVbW-1IxZtltHcLyzOy9Db6kvJbzC1Zf4q2ssemOx9T1K7chz2Kjz5nDXbCHB_dap1LLWVE8ve5T7XwduOdUrcgaEK6I00aGbDibb0L2j3NPpW115oAbx1m_2Aryl4VL2T-ye0He_JrwknqLKe8WK5sHEjWiycADH1UH2G6ehz66glOBElbCRZZbT6jjb7TZIfQz5lHCAyMtU3umIr4V-5d9SZ4CsiVgcXdvL2NAzOcPFS4OlPxfiFA5rNRwHTG0fg_WK39lGHkAg0TyzR05XkXt_cmQxMdPHWGgHYyiqQXnbpFCSEf8EBSkqpegIZ6irnLVYwh89BPPABMM3Pvco-TXKa7BRM3IodosRCuM7Dq-WtIyWVV4oZRfIZeuloLyWKxnMhgMEQl_EmQ5LRZxLNhFAm_hjDS2tKRMaXGq0YZ-8zFzk4YL2zKR0aHW9LL6xa1LmF1-NnDfm_THZRs7Ic2TVQRvxwEOWBUEWocnBLnv0xYiiy41pus_-MkQV-VFfwVBV0ycbPCQeLWtcBcawv2dcpyQ_ka2EevOewu1emRgcODaex2Y=w297-h448-no\" alt=\"image\" \/><\/div>\n<p>  \u041e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043d\u0430\u0448\u0438\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043f\u043e\u043b\u044f\u043c \u043b\u0443\u0447\u0448\u0435 \u043a\u0430\u043a \u043a \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 TextView, \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435:<\/p>\n<pre><code class=\"java\"> TextView textView = (TextView) findViewById(R.id.text_view_1);<\/code><\/pre>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/315478\/\"> https:\/\/habrahabr.ru\/post\/315478\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u0435\u043d\u044c \u0434\u043e\u0431\u0440\u044b\u0439! \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043a\u0430\u043a \u0448\u0440\u0438\u0444\u0442\u044b \u0432 Android. \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 TextView \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0448\u0440\u0438\u0444\u0442\u044b \u0432 xml \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0438\u0445 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0432 \u043f\u0440\u0435\u0432\u044c\u044e. \u0422\u0430\u043a \u0436\u0435 \u0440\u0435\u0448\u0438\u043c \u043e\u0434\u043d\u0443 \u0432\u0430\u0436\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0440\u0438\u0444\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u0431\u0435\u0437 \u0433\u043b\u044e\u043a\u043e\u0432 \u0438 \u043d\u0430\u043f\u0440\u044f\u0433\u043e\u0432 \u0434\u043b\u044f \u0431\u0440\u0430\u0442\u044c\u0435\u0432 \u043d\u0430\u0448\u0438\u0445 \u043c\u0435\u043d\u044c\u0448\u0438\u0445, \u043d\u0430\u0448\u0438\u0445 Android-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432.   <\/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-281104","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/281104","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=281104"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/281104\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=281104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=281104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=281104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}