本文整理匯總了Java中android.content.res.Resources.newTheme方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.newTheme方法的具體用法?Java Resources.newTheme怎麽用?Java Resources.newTheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.Resources
的用法示例。
在下文中一共展示了Resources.newTheme方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadResources
import android.content.res.Resources; //導入方法依賴的package包/類
protected void loadResources() {
try {
AssetManager assetManager = AssetManager.class.newInstance();
Method addAssetPath = assetManager.getClass().getMethod("addAssetPath", String.class);
addAssetPath.invoke(assetManager, dexpath);
mAssetManager = assetManager;
} catch (Exception e) {
e.printStackTrace();
}
Resources superRes = super.getResources();
superRes.getDisplayMetrics();
superRes.getConfiguration();
mResources = new Resources(mAssetManager, superRes.getDisplayMetrics(),superRes.getConfiguration());
mTheme = mResources.newTheme();
mTheme.setTo(super.getTheme());
}
示例2: hookActivityResources
import android.content.res.Resources; //導入方法依賴的package包/類
public static void hookActivityResources(Activity activity, String packageName) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && isVivo(activity.getResources())) {
// for 5.0+ vivo
return;
}
// designed for 5.0 - only, but some bad phones not work, eg:letv
try {
Context base = activity.getBaseContext();
final LoadedPlugin plugin = PluginManager.getInstance(activity).getLoadedPlugin(packageName);
final Resources resources = plugin.getResources();
if (resources != null) {
ReflectUtil.setField(base.getClass(), base, "mResources", resources);
// copy theme
Resources.Theme theme = resources.newTheme();
theme.setTo(activity.getTheme());
int themeResource = (int)ReflectUtil.getField(ContextThemeWrapper.class, activity, "mThemeResource");
theme.applyStyle(themeResource, true);
ReflectUtil.setField(ContextThemeWrapper.class, activity, "mTheme", theme);
ReflectUtil.setField(ContextThemeWrapper.class, activity, "mResources", resources);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: loadResources
import android.content.res.Resources; //導入方法依賴的package包/類
protected void loadResources() throws InstantiationException, IllegalAccessException, IllegalArgumentException,
InvocationTargetException, NoSuchMethodException, NoSuchFieldException {
Log.d(TAG, "MyApplication : loadResources()");
AssetManager am = (AssetManager) AssetManager.class.newInstance();
am.getClass().getMethod("addAssetPath", String.class).invoke(am, dexPath);
mAssetManager = am;
Constructor<?> constructor_Resources = Resources.class.getConstructor(AssetManager.class, cc.getResources()
.getDisplayMetrics().getClass(), cc.getResources().getConfiguration().getClass());
mResources = (Resources) constructor_Resources.newInstance(am, cc.getResources().getDisplayMetrics(), cc.getResources().getConfiguration());
mTheme = mResources.newTheme();
mTheme.applyStyle(android.R.style.Theme_Light_NoTitleBar_Fullscreen, true);
}