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 @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.TypedValue;
import android.view.View;

import com.facebook.react.ReactInstanceManager;
Expand All @@ -10,7 +11,6 @@
import com.reactnativenavigation.react.ReactView;

import static android.view.View.MeasureSpec.EXACTLY;
import static android.view.View.MeasureSpec.UNSPECIFIED;
import static android.view.View.MeasureSpec.makeMeasureSpec;
import static com.reactnativenavigation.utils.UiUtils.dpToPx;

Expand Down Expand Up @@ -39,7 +39,19 @@ private int createSpec(int measureSpec, Number dimension) {
if (dimension.hasValue()) {
return makeMeasureSpec(MeasureSpec.getSize(dpToPx(getContext(), dimension.get())), EXACTLY);
} else {
return makeMeasureSpec(MeasureSpec.getSize(measureSpec), UNSPECIFIED);
// When JS doesn't pass width/height, default to the theme's actionBarSize (48dp on Material).
// Yoga's intrinsic measurement of the React view collapses `paddingHorizontal` on the
// trailing edge in RTL (RN/Fabric measurement quirk), so we cannot trust UNSPECIFIED here -
// it produces a 0dp visible inset against the screen edge in RTL.
return makeMeasureSpec(resolveActionBarSize(), EXACTLY);
}
}

private int resolveActionBarSize() {
TypedValue tv = new TypedValue();
if (getContext().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
return TypedValue.complexToDimensionPixelSize(tv.data, getContext().getResources().getDisplayMetrics());
}
return (int) dpToPx(getContext(), 48f);
}
}
Binary file modified playground/e2e/assets/buttons_navbar.android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.