diff --git a/README.md b/README.md index 2faeb34..94880b9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ # Repo allowing -in a KISS way- to create a containered way to build an Android App APK +## brach `no-res.xml` + +this branch features the exmaple.app to not require the compoletely bogus unneeded requirement +to setup a `./apk/res/layouts/res.xml` file to setup the layout to be used. +Instead a layout is created inline + + ## tl;dr to `make` minimal exmaple.app via the docker-compose: diff --git a/apk/res/layout/main.xml b/apk/res/layout/main.xml deleted file mode 100644 index 187f165..0000000 --- a/apk/res/layout/main.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/apk/src/app/example/ExampleApp.java b/apk/src/app/example/ExampleApp.java index 97f29f6..5777d10 100644 --- a/apk/src/app/example/ExampleApp.java +++ b/apk/src/app/example/ExampleApp.java @@ -4,32 +4,76 @@ import android.util.Log; import android.widget.TextView; import android.app.Activity; import android.os.Bundle; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.util.concurrent.TimeUnit; import android.text.method.ScrollingMovementMethod; +import android.view.MenuItem; +import android.view.*; +import android.widget.*; +import android.view.ViewGroup.*; -public class ExampleApp extends Activity -{ +public class ExampleApp extends Activity { @Override - public void onCreate(Bundle savedInstanceState) - { - try - { - super.onCreate(savedInstanceState); - //volatile String result = "initial"; - String result = "initial"; - TextView tv = new TextView(this); - tv.setMovementMethod(new ScrollingMovementMethod()); - tv.setText( result); - setContentView(tv); - } catch (Exception e) { - throw new RuntimeException(e); - } + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // creating LinearLayout + LinearLayout linLayout = new LinearLayout(this); + // specifying vertical orientation + linLayout.setOrientation(LinearLayout.VERTICAL); + // creating LayoutParams + LayoutParams linLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); + // set LinearLayout as a root element of the screen + setContentView(linLayout, linLayoutParam); + LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + + TextView tv = new TextView(this); + tv.setText("SUPERVIEalexW"); + tv.setLayoutParams(lpView); + linLayout.addView(tv); + + Button btn = new Button(this); + btn.setText("Button"); + linLayout.addView(btn, lpView); + + + LinearLayout.LayoutParams leftMarginParams = new LinearLayout.LayoutParams( + LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + leftMarginParams.leftMargin = 50; + + Button btn1 = new Button(this); + btn1.setText("Button1"); + linLayout.addView(btn1, leftMarginParams); + + + LinearLayout.LayoutParams rightGravityParams = new LinearLayout.LayoutParams( + LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + rightGravityParams.gravity = Gravity.RIGHT; + + Button btn2 = new Button(this); + btn2.setText("Button2"); + linLayout.addView(btn2, rightGravityParams); } - - } + +// +//public class ExampleApp extends Activity +//{ +// @Override +// public void onCreate(Bundle savedInstanceState) +// { +// try +// { +// super.onCreate(savedInstanceState); +// //volatile String result = "initial"; +// String result = "initial"; +// TextView tv = new TextView(this); +// tv.setMovementMethod(new ScrollingMovementMethod()); +// tv.setText( result); +// setContentView(tv); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// +// } +// +// +//}