From 82bd01d9c88613c9b9ec16ea6fe1f294d12355e2 Mon Sep 17 00:00:00 2001 From: "Loch Christian (uib05376)" Date: Mon, 9 Nov 2020 20:04:55 +0100 Subject: [PATCH] Change View background to black, add control widgets --- app/build.gradle | 1 + .../de/hems/trafficsim/TimeRecordView.java | 7 +- app/src/main/res/layout/activity_main.xml | 230 ++++++++++++++---- 3 files changed, 193 insertions(+), 45 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0e7f480..cfde453 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,7 @@ dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.1' + implementation 'androidx.cardview:cardview:1.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' diff --git a/app/src/main/java/de/hems/trafficsim/TimeRecordView.java b/app/src/main/java/de/hems/trafficsim/TimeRecordView.java index 9ef74ef..12c3249 100644 --- a/app/src/main/java/de/hems/trafficsim/TimeRecordView.java +++ b/app/src/main/java/de/hems/trafficsim/TimeRecordView.java @@ -22,6 +22,7 @@ public class TimeRecordView extends View { this.paint = new Paint(); paint.setColor(Color.BLACK); paint.setStyle(Paint.Style.FILL_AND_STROKE); + this.setBackgroundColor(Color.BLACK); } protected int getColor(float curVelocity, float maxVelocity) { @@ -42,8 +43,8 @@ public class TimeRecordView extends View { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, 20); - setMeasuredDimension(widthMeasureSpec, 20); + super.onMeasure(widthMeasureSpec, 10); + setMeasuredDimension(widthMeasureSpec, 10); } @Override @@ -59,7 +60,7 @@ public class TimeRecordView extends View { int left = (int) (this.pixelPerVehicle * r.getPosition()); this.paint.setColor(getColor(r.getVelocity(), r.getMaxVelocity())); canvas.drawRect(left, 0, left + this.pixelPerVehicle - 1, - 20, this.paint); + 10, this.paint); i++; } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index c25b52e..4567ba7 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -8,53 +8,199 @@ tools:context=".MainActivity"> - -