浏览代码

Merge pull request #153 from HenleyKuang/master

Fix psitioning of TextureView elements relative to target element
Gaëtan Renaudeau 6 年前
父节点
当前提交
794b4bcc3e
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12
    1
      android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java

+ 12
- 1
android/src/main/java/fr/greweb/reactnativeviewshot/ViewShot.java 查看文件

@@ -180,7 +180,18 @@ public class ViewShot implements UIBlock {
180 180
             if(child instanceof TextureView) {
181 181
                 ((TextureView) child).setOpaque(false);
182 182
                 childBitmapBuffer = ((TextureView) child).getBitmap(child.getWidth(), child.getHeight());
183
-                c.drawBitmap(childBitmapBuffer, child.getLeft() + ((ViewGroup)child.getParent()).getLeft() +  child.getPaddingLeft(), child.getTop() + ((ViewGroup)child.getParent()).getTop() + child.getPaddingTop(), null);
183
+                int left = child.getLeft();
184
+                int top = child.getTop();
185
+                View parentElem = (View)child.getParent();
186
+                while (parentElem != null) {
187
+                    if (parentElem == view) {
188
+                        break;
189
+                    }
190
+                    left += parentElem.getLeft();
191
+                    top += parentElem.getTop();
192
+                    parentElem = (View)parentElem.getParent();
193
+                }
194
+                c.drawBitmap(childBitmapBuffer, left + child.getPaddingLeft(),  top + child.getPaddingTop(), null);
184 195
             }
185 196
         }
186 197