Android 主题和样式
主题和样式的区别
- 主题不能作用于单个的View组建,主题应该对整个应用中的所有Activity起作用,或对针对的Activity起作用。
- 主题定义的格式应该是改变窗口外观的格式,例如窗口标题、窗口边框等。
样式的写法:
<resources> <style name="theme_normal"> <item name="android:windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> <item name="android:windowBackground">@color/white</item> <item name="android:textColor">@color/black</item> </style> </resources>
使用主题:
setTheme(R.style.theme_normal);
super.onCreate(savedInstanceState);
setContentView(R.layout.edt_aide_memoire);
注意使用主题时候的编写顺序。SDK上写道
public void setTheme (int resid) Since: API Level 1 Set the base theme for this context. Note that this should be called before any views are instantiated in the Context (for example before calling setContentView(View) or inflate(int, ViewGroup)).
浙公网安备 33010602011771号