メインアプリにレイアウト「main_layout.xml」があり、スキン(別のアプリ)アプリにレイアウト「main_layout2.xml」があるとします。
setContentView(main_layout2)
スキンアプリがインストールされている場合、インストールされていない場合はメインアプリでどのように設定できますかsetContentView(R.layout.main_layout);
私はこれをよく知っています:
[In Theme package]
1. set action for activity, for example: my.package.theme
2. add all files you need for this theme
[In main app]
// Create intent with your action: my.package.theme
Intent intent = new Intent();
intent.setAction("my.package.theme");
// Get list of all installed packages with your themes
List<ResolveInfo> lresolve = pm.queryIntentActivities(intent, 0);
int size = lresolve.size();
for (int i = 0; i < size; i++) {
ApplicationInfo appInfo = lresolve.get
(i).activityInfo.applicationInfo;
try {
Resources resSkin = pm.getResourcesForApplication(appInfo);
int backres = resSkin.getIdentifier("my_background", "drawable",
appInfo.packageName);
// getting background from theme package
Drawable background = resSkin.getDrawable(backres);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
上記のコードで、画像を変更できます。しかし、他のアプリのxmlレイアウトをメインアプリに浸透させる方法.
これで私を助けてください(サンプルコードまたはサンプルリンク、いただければ幸いです)。
前もって感謝します。