वर्तमान में प्रोग्राम की दृष्टि से शैली को सेट करना संभव नहीं है।
इस के आसपास पाने के लिए आप, शैली सौंपा के साथ एक टेम्पलेट लेआउट एक्सएमएल फ़ाइल बनाने res/layout
में उदाहरण के लिए निम्नलिखित सामग्री के साथ के रूप में tvtemplate.xml
बना सकते हैं:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is a template"
style="@android:style/TextAppearance.DeviceDefault.Small" />
तो यह बढ़ अपने नए TextView का दृष्टांत के लिए:
TextView myText = (TextView)getLayoutInflater().inflate(R.layout.tvtemplate, null);
स्रोत
2013-02-22 08:53:40
आप किसी भी दृश्य की शैली को व्यावहारिक रूप से सेट नहीं कर सकते हैं। लेकिन आप दृश्य के व्यक्तिगत गुणों को सेट कर सकते हैं –
[एंड्रॉइड - सेट टेक्स्टव्यू टेक्स्ट स्टाइल प्रोग्रामेटिक रूप से सेट करें] के संभावित डुप्लिकेट? (http://stackoverflow.com/questions/7919173/android-set-textview-textstyle-programmatically) –