do not require a res.xml file

This commit is contained in:
Alexander Mahr 2024-10-08 11:23:30 +02:00
parent 17696caf99
commit 98eef38c7e
3 changed files with 74 additions and 36 deletions

View file

@ -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:

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="aa"
/>
</LinearLayout>

View file

@ -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);
// }
//
// }
//
//
//}