浏览代码

changed centering logic of title on android (#1164)

Kelt 7 年前
父节点
当前提交
1d73739dc5
共有 1 个文件被更改,包括 2 次插入4 次删除
  1. 2
    4
      android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java

+ 2
- 4
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java 查看文件

@@ -91,11 +91,9 @@ public class TitleBar extends Toolbar {
91 91
             @Override
92 92
             public void run() {
93 93
                 if (params.titleBarTitleTextCentered) {
94
-                    int[] location = new int[2];
95
-                    titleView.getLocationOnScreen(location);
96
-                    titleView.setTranslationX(titleView.getTranslationX() + (-location[0] + ViewUtils.getScreenWidth() / 2 - titleView.getWidth() / 2));
94
+                    titleView.setX(ViewUtils.getScreenWidth() / 2 - titleView.getWidth() / 2);
97 95
                 }
98
-
96
+                
99 97
             }
100 98
         });
101 99
     }