-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline image isn't scaled in Android version #11906
Comments
after some debugging on my own I found the reason why text inline image is not getting scaling properly, here my findings: During this commit change: 68c6d71 public TextInlineImageSpan buildInlineImageSpan() {
Resources resources = getThemedContext().getResources();
int height = (int) Math.ceil(getStyleHeight());
int width = (int) Math.ceil(getStyleWidth());
return new FrescoBasedReactTextInlineImageSpan(
resources,
height,
... to: public TextInlineImageSpan buildInlineImageSpan() {
Resources resources = getThemedContext().getResources();
int height = (int) Math.ceil(mWidth);
int width = (int) Math.ceil(mHeight);
return new FrescoBasedReactTextInlineImageSpan(
resources,
height,
... so before it was getting set from public void setWidth(float width) {
setStyleWidth(CSSConstants.isUndefined(width) ? width : PixelUtil.toPixelFromDIP(width));
} currently, this class does not apply any transformation to the width/height value so it ends up rendering without any notion of the current resolution. a workaround for now is doing something like this: class App extends Component {
render() {
const width = 80 * (Platform.OS === 'ios' ? 1 : PixelRatio.get());
const height = 80 * (Platform.OS === 'ios' ? 1 : PixelRatio.get());
return (
<View style={{flex: 1}}>
<Text style={{backgroundColor: 'red'}}>
<Image
style={{width, height}}
source={{uri: 'http://s3.hilariousgifs.com/displeased-cat.jpg'}}
/>
</Text>
</View>
);
}
} I hope this info is helpful to clarify this issue so we can expect a fix for this soon. Let me know if you guys need any more information. |
@christopherdro is there any news/progress around this issue? |
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
thx @yloeza .this work around for me |
@alexustinovsm |
I won't be reopening this issue as it does not contain sufficient information as required by the template. You may open a new one. |
The problem is simple: A new issue would loose the information in the thread. |
You can always link back to the thread and make sure the new issue summarizes any relevant information from this thread. |
When I use inline Image component with static image resources with different densities, I'll have problem in Android version with scaling of image. It looks like the app uses 1x instead of 3x image, but iOS version works fine.
Part of my code:
My static image resources:
ReactNative v0.40.0
The text was updated successfully, but these errors were encountered: