Commit d653200e704a96bdf75da3b2c534eab4d2486dd1
1 parent
f370aef7
Use xml param
Use onCLick xml param of the View to add hiding action.
Showing
2 changed files
with
12 additions
and
17 deletions
Show diff stats
app/src/main/java/fr/utbm/lo53/p2017/positionningapp/PositioningActivity.java
1 | 1 | package fr.utbm.lo53.p2017.positionningapp; |
2 | 2 | |
3 | -import android.content.Intent; | |
4 | 3 | import android.os.Bundle; |
5 | 4 | import android.support.constraint.ConstraintLayout; |
6 | -import android.support.design.widget.FloatingActionButton; | |
7 | -import android.support.design.widget.Snackbar; | |
8 | -import android.support.v7.app.AppCompatActivity; | |
9 | 5 | import android.support.v7.widget.Toolbar; |
10 | -import android.text.Layout; | |
11 | 6 | import android.view.Menu; |
12 | 7 | import android.view.MenuItem; |
13 | 8 | import android.view.View; |
14 | 9 | import android.view.animation.AccelerateInterpolator; |
15 | 10 | import android.view.animation.AlphaAnimation; |
16 | 11 | import android.view.animation.Animation; |
17 | -import android.widget.Button; | |
18 | 12 | import android.widget.ImageView; |
19 | 13 | |
20 | 14 | public class PositioningActivity extends BaseActivity { |
21 | 15 | |
16 | + private static final String TAG = "PositioningActivity"; | |
17 | + | |
22 | 18 | private ConstraintLayout start_layout; |
19 | + private Animation hideAnimation; | |
23 | 20 | |
24 | 21 | @Override |
25 | 22 | protected void onCreate(Bundle savedInstanceState) { |
... | ... | @@ -28,15 +25,8 @@ public class PositioningActivity extends BaseActivity { |
28 | 25 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); |
29 | 26 | setSupportActionBar(toolbar); |
30 | 27 | |
31 | - final Animation hideAnimation = createFadeOutAndHideAnimation(); | |
32 | - | |
33 | 28 | start_layout = (ConstraintLayout) findViewById(R.id.start_layout); |
34 | - start_layout.setOnClickListener(new View.OnClickListener() { | |
35 | - @Override | |
36 | - public void onClick(View v) { | |
37 | - start_layout.startAnimation(hideAnimation);; | |
38 | - } | |
39 | - }); | |
29 | + hideAnimation = createFadeOutAndHideAnimation(); | |
40 | 30 | } |
41 | 31 | |
42 | 32 | @Override |
... | ... | @@ -47,9 +37,13 @@ public class PositioningActivity extends BaseActivity { |
47 | 37 | return true; |
48 | 38 | } |
49 | 39 | |
40 | + public void startLocating(View v) { | |
41 | + start_layout.startAnimation(hideAnimation); | |
42 | + } | |
43 | + | |
50 | 44 | private Animation createFadeOutAndHideAnimation() { |
51 | 45 | ImageView hiding_image = (ImageView) findViewById(R.id.hiding_image); |
52 | - float initial_alpha = hiding_image.getImageAlpha(); | |
46 | + final float initial_alpha = hiding_image.getImageAlpha() / 255; | |
53 | 47 | Animation animation = new AlphaAnimation(initial_alpha, 0); |
54 | 48 | animation.setInterpolator(new AccelerateInterpolator()); |
55 | 49 | animation.setDuration(1000); | ... | ... |
app/src/main/res/layout/content_positioning.xml
... | ... | @@ -27,6 +27,7 @@ |
27 | 27 | android:id="@+id/start_layout" |
28 | 28 | android:layout_width="0dp" |
29 | 29 | android:layout_height="0dp" |
30 | + android:onClick="startLocating" | |
30 | 31 | android:visibility="visible" |
31 | 32 | app:layout_constraintBottom_toBottomOf="parent" |
32 | 33 | app:layout_constraintLeft_toLeftOf="parent" |
... | ... | @@ -34,6 +35,7 @@ |
34 | 35 | app:layout_constraintTop_toTopOf="parent"> |
35 | 36 | |
36 | 37 | <ImageView |
38 | + android:id="@+id/hiding_image" | |
37 | 39 | android:layout_width="0dp" |
38 | 40 | android:layout_height="0dp" |
39 | 41 | android:alpha=".85" |
... | ... | @@ -41,8 +43,7 @@ |
41 | 43 | app:layout_constraintLeft_toLeftOf="parent" |
42 | 44 | app:layout_constraintRight_toRightOf="parent" |
43 | 45 | app:layout_constraintTop_toTopOf="parent" |
44 | - app:srcCompat="@android:color/background_dark" | |
45 | - android:id="@+id/hiding_image" /> | |
46 | + app:srcCompat="@android:color/background_dark" /> | |
46 | 47 | |
47 | 48 | <TextView |
48 | 49 | android:layout_width="wrap_content" | ... | ... |