Skip to content

Commit 9daf7b1

Browse files
committed
write fragment layout file during the build
Signed-off-by: Umair Khan <[email protected]>
1 parent 20312e5 commit 9daf7b1

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/processing/mode/android/AndroidBuild.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,11 @@ private void writeLocalProps(final File file) {
767767
private void writeRes(File resFolder,
768768
String className) throws SketchException {
769769
File layoutFolder = mkdirs(resFolder, "layout");
770-
File layoutFile = new File(layoutFolder, "main.xml");
771-
writeResLayoutMain(layoutFile);
770+
File mainActivityLayoutFile = new File(layoutFolder, "main.xml");
771+
writeResLayoutMainActivity(mainActivityLayoutFile);
772+
773+
File mainFragmentLayoutFile = new File(layoutFolder, "fragment_main.xml");
774+
writeResLayoutMainFragment(mainFragmentLayoutFile);
772775

773776
// write the icon files
774777
File sketchFolder = sketch.getFolder();
@@ -875,7 +878,7 @@ private void writeMainActivity(final File file) {
875878
}
876879

877880

878-
private void writeResLayoutMain(final File file) {
881+
private void writeResLayoutMainActivity(final File file) {
879882
final PrintWriter writer = PApplet.createWriter(file);
880883
writer.println("<fragment xmlns:android=\"http://schemas.android.com/apk/res/android\"");
881884
writer.println(" xmlns:tools=\"http://schemas.android.com/tools\"");
@@ -887,6 +890,17 @@ private void writeResLayoutMain(final File file) {
887890
writer.flush();
888891
writer.close();
889892
}
893+
894+
895+
private void writeResLayoutMainFragment(final File file) {
896+
final PrintWriter writer = PApplet.createWriter(file);
897+
writer.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
898+
writer.println("<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"");
899+
writer.println(" android:orientation=\"vertical\"");
900+
writer.println(" android:layout_width=\"fill_parent\"");
901+
writer.println(" android:layout_height=\"fill_parent\">");
902+
writer.println("</LinearLayout>");
903+
}
890904

891905

892906
// This recommended to be a string resource so that it can be localized.

0 commit comments

Comments
 (0)