【问题标题】:How can I give Negative value to Height or Width of a View in React Naitve?如何在 React Native 中为视图的高度或宽度赋予负值?
【发布时间】:2017-06-13 05:28:48
【问题描述】:

我正在尝试使用 reactNative 中的 PANRESPONDER 在 react native 中创建选择器。实际上 View 的宽度是从左到右的,而 View 的高度是从上到下的。我想动态反转盒子。 所以我将宽度和高度作为负值。但是视图消失了。我怎样才能反转视图?

【问题讨论】:

标签: react-native react-native-android


【解决方案1】:

如果有人最终在这里寻找如何使屏幕尺寸为负值,以便您可以在滑块中移动元素..

let screenWidth = Dimensions.get('window').width;
let screenWidthNegative = parseInt('-' + screenWidth);

<View style={[styles.thisViewsStyle, {marginLeft: screenWidthNegative}]}></View>

【讨论】:

  • let screenWidthNegative = -screenWidth; 工作更轻松
猜你喜欢
  • 2019-07-11
  • 1970-01-01
  • 2017-01-22
  • 2016-01-30
  • 1970-01-01
  • 1970-01-01
  • 2016-02-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多