我对原生css样式很陌生..并具有以下代码:

 <Text>
<Text style={(styles.author, { textAlign: "left" })}>
    {question.view_count + " views\t" + question.comment_count}
    {question.comment_count > 1 || question.comment_count == 0
        ? " comments"
        : " comment"}
</Text>
<Text style={{ textAlign: "right" }}>
    {question.solution_count > 0
        ? question.solution_count + " solutions"
        : " Solve this"}
</Text>
</Text>;

问题是第二个"textAlign:'right'"不起作用——文本仍然在左边.我希望文本在同一行,但是(显然)第二个文本对象在右边.

有什么提示吗?谢谢

edit

推荐答案

变通-

<View style={{flex: 1, flexDirection: 'row'}}>
  <View style={{flex: 1}}>
    <Text>4 Views 0 Comments</Text>
  </View>
  <View style={{flex: 1}}>
    <Text style={{textAlign: 'right'}}>Solve This</Text>
  </View>
</View>

React-native相关问答推荐

expo 使用错误的版本代码创建建筑

@testing-library/react-native -> 渲染 -> TypeError:无法读取未定义的属性(读取存在)

FlatList 总是增长到 100% 高度

react-native 签名 [AppName]Tests 需要开发团队 ios

React-native 在浏览器中打开链接并返回应用程序

React-Native iOS - 如何通过按下按钮从 React-Native 视图导航到非 React-Native 视图(本机 iOS 视图控制器)?

textAlignVertical不是有效的样式属性

Property body[41] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression"

react native图像不适用于特定 URL

React Native:组件卸载时的动画

React Native + Jest EMFILE:too many open files error

如果我有 AngularJS 基础知识,怎么学习Thinking in ReactJS呢?

通过 ToolbarAndroid => onIconClicked 显示 DrawerLayoutAndroid

DeviceInfo 原生模块未正确安装

react-navigation模式高度

动态改变 React Native Flat List 中的列数

ReactNative TextInput 不可见 iOS

如何在 react-native 中为在后台杀死的 android 应用程序保持状态

React native - 以编程方式判断是否启用了远程 JS 调试

如何为 TouchableOpacity 组件创建禁用样式?