Browse Source

Fix misaligned text in CollapsingTextView (#1418)

Guy Carmeli 7 years ago
parent
commit
66bc1ef7a0

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/utils/ViewUtils.java View File

173
         return new Point(xy[0], xy[1]);
173
         return new Point(xy[0], xy[1]);
174
     }
174
     }
175
 
175
 
176
-    private static int getStatusBarHeight() {
176
+    public static int getStatusBarHeight() {
177
         if (statusBarHeight > 0) {
177
         if (statusBarHeight > 0) {
178
             return statusBarHeight;
178
             return statusBarHeight;
179
         }
179
         }

+ 6
- 4
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/CollapsingTextView.java View File

11
 import android.support.v7.widget.TintTypedArray;
11
 import android.support.v7.widget.TintTypedArray;
12
 import android.text.TextPaint;
12
 import android.text.TextPaint;
13
 import android.text.TextUtils;
13
 import android.text.TextUtils;
14
+import android.util.Log;
14
 import android.view.animation.DecelerateInterpolator;
15
 import android.view.animation.DecelerateInterpolator;
15
 import android.view.animation.Interpolator;
16
 import android.view.animation.Interpolator;
16
 import android.widget.FrameLayout;
17
 import android.widget.FrameLayout;
20
 import com.reactnativenavigation.R;
21
 import com.reactnativenavigation.R;
21
 import com.reactnativenavigation.params.StyleParams;
22
 import com.reactnativenavigation.params.StyleParams;
22
 import com.reactnativenavigation.utils.ViewUtils;
23
 import com.reactnativenavigation.utils.ViewUtils;
24
+import com.reactnativenavigation.views.utils.Point;
25
+
26
+import static android.R.attr.y;
23
 
27
 
24
 public class CollapsingTextView extends FrameLayout {
28
 public class CollapsingTextView extends FrameLayout {
25
     private static final float TEXT_SCALE_FACTOR = 1.75f;
29
     private static final float TEXT_SCALE_FACTOR = 1.75f;
123
     }
127
     }
124
 
128
 
125
     private void calculateTextPosition(Canvas canvas) {
129
     private void calculateTextPosition(Canvas canvas) {
126
-        final int[] positionOnScreen = new int[2];
127
-        getLocationInWindow(positionOnScreen);
128
-        currentY = initialY = positionOnScreen[1] + canvas.getHeight() - dummy.getMeasuredHeight();
130
+        currentY = initialY = ViewUtils.getStatusBarHeight() + canvas.getHeight() - dummy.getMeasuredHeight();
129
         float bottomMargin = ViewUtils.convertDpToPixel(10);
131
         float bottomMargin = ViewUtils.convertDpToPixel(10);
130
-        collapseY = positionOnScreen[1] + bottomMargin;
132
+        collapseY = ViewUtils.getStatusBarHeight() + bottomMargin;
131
     }
133
     }
132
 
134
 
133
     private float linearInterpolation(float from, float to, float fraction) {
135
     private float linearInterpolation(float from, float to, float fraction) {