Commit aeff84be71385e117b1a60756cd07c51b1bdeeaf
1 parent
6cff4d38
Add MapMarker and images
Showing
5 changed files
with
52 additions
and
7 deletions
Show diff stats
app/src/main/java/fr/utbm/lo53/p2017/positionningapp/Calibration.java
@@ -5,14 +5,17 @@ import android.support.design.widget.FloatingActionButton; | @@ -5,14 +5,17 @@ import android.support.design.widget.FloatingActionButton; | ||
5 | import android.support.design.widget.Snackbar; | 5 | import android.support.design.widget.Snackbar; |
6 | import android.support.v7.app.AppCompatActivity; | 6 | import android.support.v7.app.AppCompatActivity; |
7 | import android.support.v7.widget.Toolbar; | 7 | import android.support.v7.widget.Toolbar; |
8 | +import android.view.MotionEvent; | ||
8 | import android.view.View; | 9 | import android.view.View; |
9 | import android.view.Menu; | 10 | import android.view.Menu; |
10 | import android.view.MenuItem; | 11 | import android.view.MenuItem; |
12 | +import android.widget.ImageView; | ||
11 | 13 | ||
12 | public class Calibration extends AppCompatActivity { | 14 | public class Calibration extends AppCompatActivity { |
13 | 15 | ||
14 | @Override | 16 | @Override |
15 | protected void onCreate(Bundle savedInstanceState) { | 17 | protected void onCreate(Bundle savedInstanceState) { |
18 | + | ||
16 | super.onCreate(savedInstanceState); | 19 | super.onCreate(savedInstanceState); |
17 | setContentView(R.layout.activity_calibration); | 20 | setContentView(R.layout.activity_calibration); |
18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | 21 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); |
@@ -22,10 +25,30 @@ public class Calibration extends AppCompatActivity { | @@ -22,10 +25,30 @@ public class Calibration extends AppCompatActivity { | ||
22 | fab.setOnClickListener(new View.OnClickListener() { | 25 | fab.setOnClickListener(new View.OnClickListener() { |
23 | @Override | 26 | @Override |
24 | public void onClick(View view) { | 27 | public void onClick(View view) { |
25 | - Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) | 28 | + Snackbar.make(view, "Salut ! :) Ce bouton ne sert à rien.", Snackbar.LENGTH_LONG) |
26 | .setAction("Action", null).show(); | 29 | .setAction("Action", null).show(); |
27 | } | 30 | } |
28 | }); | 31 | }); |
32 | + | ||
33 | + final ImageView Map = (ImageView) findViewById(R.id.Map); | ||
34 | + final ImageView MapMarker = (ImageView) findViewById(R.id.MapMarker); | ||
35 | + | ||
36 | + MapMarker.setVisibility(MapMarker.INVISIBLE); | ||
37 | + | ||
38 | + Map.setOnTouchListener(new View.OnTouchListener() { | ||
39 | + @Override | ||
40 | + public boolean onTouch(View view, MotionEvent motionEvent) { | ||
41 | + if(motionEvent.getAction()==motionEvent.ACTION_MOVE) { | ||
42 | + MapMarker.setVisibility(MapMarker.VISIBLE); | ||
43 | + Snackbar.make(view, " X : " + motionEvent.getX() + " Y : " + motionEvent.getY(), Snackbar.LENGTH_LONG) | ||
44 | + .setAction("Action", null).show(); | ||
45 | + MapMarker.setX(motionEvent.getX()-(MapMarker.getWidth()/4)); | ||
46 | + MapMarker.setY(motionEvent.getY()-(MapMarker.getHeight()/4)); | ||
47 | + } | ||
48 | + return true; | ||
49 | + } | ||
50 | + | ||
51 | + }); | ||
29 | } | 52 | } |
30 | 53 | ||
31 | @Override | 54 | @Override |
4.55 KB
11.2 KB
app/src/main/res/layout/activity_calibration.xml
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | xmlns:tools="http://schemas.android.com/tools" | 4 | xmlns:tools="http://schemas.android.com/tools" |
5 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
7 | + android:background="#000000" | ||
7 | tools:context="fr.utbm.lo53.p2017.positionningapp.Calibration"> | 8 | tools:context="fr.utbm.lo53.p2017.positionningapp.Calibration"> |
8 | 9 | ||
9 | <android.support.design.widget.AppBarLayout | 10 | <android.support.design.widget.AppBarLayout |
@@ -20,7 +21,7 @@ | @@ -20,7 +21,7 @@ | ||
20 | 21 | ||
21 | </android.support.design.widget.AppBarLayout> | 22 | </android.support.design.widget.AppBarLayout> |
22 | 23 | ||
23 | - <include layout="@layout/content_calibration" /> | 24 | + <include layout="@layout/content_calibration"/> |
24 | 25 | ||
25 | <android.support.design.widget.FloatingActionButton | 26 | <android.support.design.widget.FloatingActionButton |
26 | android:id="@+id/fab" | 27 | android:id="@+id/fab" |
app/src/main/res/layout/content_calibration.xml
@@ -8,13 +8,34 @@ | @@ -8,13 +8,34 @@ | ||
8 | tools:context="fr.utbm.lo53.p2017.positionningapp.Calibration" | 8 | tools:context="fr.utbm.lo53.p2017.positionningapp.Calibration" |
9 | tools:showIn="@layout/activity_calibration"> | 9 | tools:showIn="@layout/activity_calibration"> |
10 | 10 | ||
11 | - <TextView | ||
12 | - android:layout_width="wrap_content" | 11 | + <ImageView |
12 | + android:id="@+id/Map" | ||
13 | + android:layout_width="0dp" | ||
13 | android:layout_height="wrap_content" | 14 | android:layout_height="wrap_content" |
14 | - android:text="Hello World!" | ||
15 | - app:layout_constraintBottom_toBottomOf="parent" | 15 | + android:layout_marginLeft="8dp" |
16 | + android:layout_marginRight="8dp" | ||
17 | + android:layout_marginTop="30dp" | ||
18 | + android:paddingLeft="0dp" | ||
19 | + android:paddingTop="0dp" | ||
20 | + android:scaleType="fitXY" | ||
21 | + app:layout_constraintHorizontal_bias="0.0" | ||
16 | app:layout_constraintLeft_toLeftOf="parent" | 22 | app:layout_constraintLeft_toLeftOf="parent" |
17 | app:layout_constraintRight_toRightOf="parent" | 23 | app:layout_constraintRight_toRightOf="parent" |
18 | - app:layout_constraintTop_toTopOf="parent" /> | 24 | + app:layout_constraintTop_toTopOf="parent" |
25 | + app:srcCompat="@drawable/map" /> | ||
26 | + | ||
27 | + <ImageView | ||
28 | + android:id="@+id/MapMarker" | ||
29 | + android:layout_width="42dp" | ||
30 | + android:layout_height="46dp" | ||
31 | + app:srcCompat="@drawable/map_marker" | ||
32 | + android:layout_marginRight="8dp" | ||
33 | + app:layout_constraintRight_toRightOf="parent" | ||
34 | + android:layout_marginLeft="8dp" | ||
35 | + app:layout_constraintLeft_toLeftOf="parent" | ||
36 | + app:layout_constraintTop_toTopOf="@+id/Map" | ||
37 | + android:layout_marginTop="8dp" | ||
38 | + app:layout_constraintBottom_toBottomOf="@+id/Map" | ||
39 | + android:layout_marginBottom="8dp" /> | ||
19 | 40 | ||
20 | </android.support.constraint.ConstraintLayout> | 41 | </android.support.constraint.ConstraintLayout> |