question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image nested in Text only show half content part on Android.

See original GitHub issue

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

When an Image is nested in Text, only half part content would be showed on android.

React Native version:

Run react-native info in your terminal and copy the results here.

info
  React Native Environment Info:
    System:
      OS: macOS 10.15.5
      CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
      Memory: 30.19 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.3.0 - ~/.nvm/versions/node/v8.3.0/bin/node
      Yarn: 1.22.4 - ~/.nvm/versions/node/v8.3.0/bin/yarn
      npm: 6.8.0 - ~/.nvm/versions/node/v8.3.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 24.0.1, 25.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.1, 27.0.3, 28.0.3
        System Images: android-27 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 11.5/11E608c - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.10.2 => 16.10.2
      react-native: ^0.59.10 => 0.59.10
    npmGlobalPackages:
      create-react-native-module: 0.19.0
      react-native-cli: 2.0.1

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. put a <Image/> inside <Text/> component
  2. run on android

Expected Results

Image would show full content.

Snack, code example, screenshot, or link to a repository:

render() {
    const uri = 'https://cdn.sspai.com//2020/08/01/f91d9770d0d5d2bb270fa9340384a274.png?imageView2/2/w/1120/q/90/interlace/1/ignore-error/1'
    const width = Dimensions.get('window').width
    const height = width * 0.6231481481481481 // h/w ratio of the example image

    return (<Text style={{ width, height, backgroundColor:'blue', }}>
            <Image source={{uri}} style={{
                width,
                height,
                resizeMode: 'contain',
            }}/>
            </Text>
           )
}

Screen Shot 2020-08-04 at 11 36 44

Extra

Everything is fine on iOS, this issue only occurs on Android.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
pperroncommented, Jan 14, 2021

I had the same issue, getting only half of my image. To solve my issue, I set a fontSize big enough to handle my image. My image was 100x100, so I gave <Text> a fontSize:150 and it display my image ok on Android. I did a condition to handle IOS and Android differently since IOS working fine without any fontsize.

Hope it can help someone else 😉

0reactions
keane032commented, Apr 1, 2021

same

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to place one view over another in android?
But in Linear/Relative Layout, views can be placed only one after another or relative to each other, and AbsoluteLayout is advised against. So...
Read more >
Reveal or hide a view using animation - Android Developers
There are three common animations to use when showing or hiding a view. You can use the circular reveal animation, a crossfade animation, ......
Read more >
Why My Text Is Going Off Screen? The Truth about React ...
The blue element has a parent-driven width. It also has a content-driven height: fits to what is inside only. The parent-driven width is...
Read more >
Copy, insert graphics - Adobe Support
Learn to place graphics, import images, and insert pictures or other ... If you've selected Text only, you'll see the Paste text only...
Read more >
Add or edit text & images - Sites Help - Google Support
Tip: This section is for new Google Sites. ... You can add images in .png, .jpg, or .gif format. ... Add text, headings,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found