我正在使用颤振,并且试图将图像的纵横比从 4:3 更改为 16:9。我曾尝试使用 AspectRatio Widget 并使用 FittedBox 但图像仍然是 4:3
我尝试使用 AspectRatio,将 Image 上的 fit 属性更改为覆盖、适合和包含
Card(elevation: 3.0, child: Column(
children: <Widget>[Container(child:
AspectRatio(aspectRatio: 16.0 / 9.0, child: FittedBox(fit:
BoxFit.contain,
child: Image(image: AssetImage('images/maggie.jpg')),),)
)],
Run Code Online (Sandbox Code Playgroud) 根据 React Native API 文档中的这个链接:https : //facebook.github.io/react-native/docs/0.59/textinput#isfocused
TextInput 组件有一个名为 isFocused() 的方法。我将如何访问此方法?我必须使用 ref 吗?
此外,我已经知道我可以通过使用 onFocus 道具并设置状态管理器和基于 onFocus 更改输入状态的函数来实现相同的效果。但是,我很好奇我将如何使用这些组件方法,因为其他组件中也有其他方法。
我试过用这个
<TextInput onChangeText={this.handleText} style={(this.isFocused()) ? styles.input : styles.lame} placeholder="Names"/>
Run Code Online (Sandbox Code Playgroud)
但看起来我可能不得不使用 ref,因为它似乎没有定义,即使该方法应该是这个组件的一部分。