瀏覽代碼

fix margin top topbar when statusbar drawbehind (#5209)

Igor 6 年之前
父節點
當前提交
234c59ce7b
共有 1 個檔案被更改,包括 5 行新增1 行删除
  1. 5
    1
      lib/android/app/src/main/java/com/reactnativenavigation/views/ComponentLayout.java

+ 5
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/ComponentLayout.java 查看文件

95
     public void drawBelowTopBar(TopBar topBar) {
95
     public void drawBelowTopBar(TopBar topBar) {
96
         if (getLayoutParams() instanceof RelativeLayout.LayoutParams) {
96
         if (getLayoutParams() instanceof RelativeLayout.LayoutParams) {
97
             RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
97
             RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
98
-            layoutParams.topMargin = ViewUtils.getHeight(topBar);
98
+            if (topBar.getLayoutParams() instanceof MarginLayoutParams) {
99
+                layoutParams.topMargin = ViewUtils.getHeight(topBar) + ((MarginLayoutParams) topBar.getLayoutParams()).topMargin;
100
+            } else {
101
+                layoutParams.topMargin = ViewUtils.getHeight(topBar);
102
+            }
99
             try {
103
             try {
100
                 setLayoutParams(layoutParams);
104
                 setLayoutParams(layoutParams);
101
             } catch (IllegalStateException ignored) { }
105
             } catch (IllegalStateException ignored) { }