Android中Theme的作用是什么
今天就跟大家聊聊有关Android中Theme的作用是什么,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
首先在values下新建一个theme.xml,用来定义需要的theme了,代码如下:
Xml代码
< ?xml version="1.0" encoding="utf-8"?> < resources> < style name="theme" parent="android:Theme.Black"> < item name="android:windowNoTitle">true< /item> < item name="android:textSize">14sp< /item> < item name="android:textColor">#FFFF0000< /item> < /style> < /resources> < ?xml version="1.0" encoding="utf-8"?> < resources> < style name="theme" parent="android:Theme.Black"> < item name="android:windowNoTitle">true< /item> < item name="android:textSize">14sp< /item> < item name="android:textColor">#FFFF0000< /item> < /style> < /resources>
Android Theme的用法是不是跟style的很相似?
然后你可以在需要的那个activity上引用,加上
Java代码
setTheme(R.style.theme); setTheme(R.style.theme);
这句代码就ok了。
当然,你也可以在AndroidManifest.xml中定义把主题运用到整个application或者具体的activity中,代码:
Xml代码
< application android:icon="@drawable/icon"
android:label="@string/app_name"android:theme="@style/theme">
< application android:icon="@drawable/icon"
android:label="@string/app_name"android:theme="@style/theme">
在application属性加上一句就可以了。如果你需要为特定的activity指定Android Theme,你只要把这句加到AndroidManifest.xml中activity中的属性就ok。
看完上述内容,你们对Android中Theme的作用是什么有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。