TextView is not correctly sized if it is styled with maxWidth
See original GitHub issueThe text in the TextView is being partially displayed if its stylesheet contains maxWidth
property.
Screenshot with maxWidth: 300
:
Screenshot without using maxWidth
:
Minimal code snippet:
import React, { Component } from 'react';
import { AppRegistry, View, Text, StyleSheet } from 'react-native';
import Dimensions from 'Dimensions';
export default class Message extends Component {
constructor(props) {
super(props);
}
render() {
return (
<Text style={ styles.bubble }>{ this.props.sender }: { this.props.text }</Text>
);
}
}
const styles = StyleSheet.create({
bubble: {
maxWidth: 300, // the bug occurs only when maxWidth is present in the styles
marginBottom: 10,
padding: 10,
backgroundColor: '#0086EF',
}
});
Works correct on Android, the problem occurs only in iOS (EDIT 09.08.2016: after testing it again with Android I can reproduce the problem there also, so it affects iOS and Android). react-native: 0.31.0
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Auto Scale TextView Text to Fit within Bounds - Stack Overflow
I have got an edittext and textview in my layout. The textview is fixed height and width. When the user starts to type...
Read more >TextView - Android Developers
To customize the appearance of TextView, see Styles and Themes. ... android:autoSizeStepGranularity, Specify the auto-size step size if autoSizeTextType is ...
Read more >Frame Behaviors with SwiftUI
This animation shows the difference between using fixedSize or leaving it unspecified. When we set the size as fixed, the Text view can...
Read more >text-size-adjust - CSS: Cascading Style Sheets - MDN Web Docs
When an element containing text uses 100% of the screen's width, the algorithm increases its text size, but without modifying the layout.
Read more >Android - TextView Control - Tutorialspoint
A TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just came across something that looks quite similar. I can repro on Android, but not 100% about iOS yet.
Minimal RN Play example that shows the problem on android: https://rnplay.org/apps/aSc6cw
Top text line has
maxWidth: 300
applied and shows the text getting cut off.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.