feat(android): textZoom prop to limit scaling issues (#414)

When setting a custom font size in the Android system, an undesirable scale of the site interface in WebView occurs.

I researched that when setting the standard textZoom (100) parameter size, this undesirable effect disappears.

This can be very useful if you need to avoid the scale of content in WebView when changing the size of system fonts, or change textZoom property directly.

Example:

`
<WebView
  textZoom={100}
/>
`
This commit is contained in:
mr.sadvit 2019-03-28 11:52:18 +03:00 committed by Thibault Malbranche
parent 07ce4fdc8f
commit 82fe6e2c3d
2 changed files with 12 additions and 0 deletions

View File

@ -318,6 +318,11 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
}
}
@ReactProp(name = "textZoom")
public void setTextZoom(WebView view, int value) {
view.getSettings().setTextZoom(value);
}
@ReactProp(name = "scalesPageToFit")
public void setScalesPageToFit(WebView view, boolean enabled) {
view.getSettings().setLoadWithOverviewMode(enabled);

View File

@ -237,6 +237,7 @@ export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
onContentSizeChange?: (event: WebViewEvent) => void;
overScrollMode?: OverScrollModeType;
saveFormDataDisabled?: boolean;
textZoom?: number;
thirdPartyCookiesEnabled?: boolean;
urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
}
@ -480,6 +481,12 @@ export interface AndroidWebViewProps extends WebViewSharedProps {
*/
userAgent?: string;
/**
* Sets number that controls text zoom of the page in percent.
* @platform android
*/
textZoom?: number;
/**
* Specifies the mixed content mode. i.e WebView will allow a secure origin to load content from any other origin.
*