Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,35 @@ private void tryFallbackDraw(int w, int h) {
try {
final Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(bmp);
// Draw the view hierarchy (includes background + children)
((View)view).draw(canvas);

// Get the parent container that holds both the CodenameOneSurface and PeerComponents
View viewToDraw = (View)view;
android.view.ViewParent parent = viewToDraw.getParent();

// If the view has a parent (relativeLayout), draw the parent to include PeerComponents
// Otherwise fall back to drawing just the view
if (parent instanceof View) {
View parentView = (View) parent;
// Save the parent's current position
final int[] parentLoc = new int[2];
parentView.getLocationInWindow(parentLoc);
final int[] viewLoc = new int[2];
viewToDraw.getLocationInWindow(viewLoc);

// Calculate offset between view and parent
final int offsetX = viewLoc[0] - parentLoc[0];
final int offsetY = viewLoc[1] - parentLoc[1];

// Translate canvas to align view content correctly
canvas.translate(-offsetX, -offsetY);

// Draw the parent view hierarchy (includes PeerComponents as siblings)
parentView.draw(canvas);
} else {
// Fallback: draw only the view if no parent found
viewToDraw.draw(canvas);
}

postSuccess(bmp);
} catch (Throwable t) {
Log.e(t);
Expand Down
Binary file modified scripts/android/screenshots/BrowserComponent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading