我们可以在活动中使用getTheme()
来获取当前主题。但是如何打印这个检索到的主题的名称呢?
没有像getTheme().getName()
这样的方法。我尝试使用resolveAttribute
和obtainStyledAttributes
,但没有成功。
发布于 2014-11-29 05:10:56
你可以这样做:
int theme = 0;
try
{
String packageName = getClass().getPackage().getName();
PackageInfo packageInfo = getPackageManager().getPackageInfo(packageName, PackageManager.GET_META_DATA);
theme = packageInfo.applicationInfo.theme;
}
catch (Exception e)
{
e.printStackTrace();
}
https://stackoverflow.com/questions/27195835
复制相似问题