Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

size of sketch in an processing 3 android app

$
0
0

Hi,

I'm trying to port a processing 2 android application to a processing 3 android application using android studio. So far I've been able to launch the app on my phone. However, the original sketch only appears within a 100 x 100 pixel square in the center of the screen (it should cover the whole screen).

This is what I got so far.

res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"
    tools:context=".MainActivity">
    <FrameLayout android:id="@+id/mysketch"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_marginBottom="0dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />
</RelativeLayout>

java/test/mysketch/MainActivity.java:

package test.mysketch;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.view.WindowManager;

public class MainActivity extends Activity {
    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        FragmentManager fragmentManager = getFragmentManager();
        Fragment fragment = new VideOSC();
        fragmentManager.beginTransaction()
                .replace(R.id.videosc, fragment)
                .commit();
    }
}

java/test/mysketch/MySketch.java:

package test.mysketch;

public class MySketch extends Activity {
    static int width, height;
    private static String TAG = "MySketch";

    public void setup() {
        View view = this.getView();
        if (view != null) {
            width = view.getWidth();
            height = view.getHeight();
        }
        noStroke();
        fill(0);
    }

    public void draw() {
        // posted result seems to correctly reflect available screen width/height,
        // yet, sketch appears to be 100 x 100 pixels big
        Log.d(TAG, "dimensions: " + width + ", " + height);
    }
}

Any clues?

Thanks very much,

Stefan


Viewing all articles
Browse latest Browse all 941

Trending Articles