在Android React Native中隐藏刷新控件

在Android React Native中隐藏刷新控件,android,reactjs,react-native,react-native-android,Android,Reactjs,React Native,React Native Android,我有一个要求,我想完全隐藏Android刷新控制的刷新指示器。我已经设置了大多数颜色属性为透明的仍然看到灰色圆形指示器。有没有办法完全隐藏这个圆形指示器。链接到gif,了解发生了什么: 这是我的代码: import React, {Component} from 'react'; import { StyleSheet, Text, TextInput, View, FlatList, Dimensions, RefreshControl, ToastAndroi

我有一个要求,我想完全隐藏Android刷新控制的刷新指示器。我已经设置了大多数颜色属性为透明的仍然看到灰色圆形指示器。有没有办法完全隐藏这个圆形指示器。链接到gif,了解发生了什么:

这是我的代码:

import React, {Component} from 'react';
import {
  StyleSheet,
  Text,
  TextInput,
  View,
  FlatList,
  Dimensions,
  RefreshControl,
  ToastAndroid,
} from 'react-native';


import Constants from './Constants';



export default class TestList extends Component {

  constructor(props) {
    super(props);
    this.rows =[{id: 1},{id: 2},{id: 3},{id: 4}];
    this.state = {
      refreshing: false,
    }
  }


  renderItem(row) {
    return (
      <Text style={{fontSize: 20, borderBottomWidth: 1, borderColor: 'red', color: 'blue', height:80}}>{row.item.id}</Text>
      )
    }
  render() {
    return (
      <View style={[styles.container]}>
        <FlatList
          data={this.rows}
          renderItem={this.renderItem.bind(this)}
          overScrollMode='always'
          style={{flex: 1}}
          keyExtractor={(item) => item.id}
          removeClippedSubviews={false}
          keyboardShouldPersistTaps='always'
          refreshControl={
            <RefreshControl
              colors={['transparent']}
              style={{backgroundColor: 'transparent'}}
              progressBackgroundColor='transparent'
              refreshing={this.state.refreshing}
              onRefresh={() =>
              ToastAndroid.show('Refresh completed with short duration', ToastAndroid.SHORT)}/>}
          ref="FlatList"/>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
})


  [1]: http://imgur.com/dkAmkC6

可以有条件地呈现RefreshControl组件,使其仅在需要时呈现

react文档在此讨论了一些技术:


但为了简单起见,我更喜欢使用npm模块根据组件状态或redux存储中的标志有条件地呈现组件

这在iOS上对我有效,但在Android上没有测试过:

refreshControl={
  <RefreshControl
      refreshing={false}
      onRefresh={this.onRefreshHandler.bind(this)}
      title='Pull to refresh'
      tintColor='transparent'
   />
}
您可以从react native使用平台api

import { Platform } from 'react-native'

<Flatlist
  ...other props
  refreshControl={
    Platform.select({
     ios: (
       <RefreshControl
          colors={['transparent']}
          style={{backgroundColor: 'transparent'}}
          progressBackgroundColor='transparent'
          refreshing={this.state.refreshing}
          onRefresh={() =>
            ToastAndroid.show(
             'Refresh completed with short duration',
             ToastAndroid.SHORT
            )
          }
       />
     )
    })
  }
/>


我有同样的问题,想要同样的东西,但没有得到它的android,所以我尝试道具。progressViewOffset={number},直到在视图上方隐藏加载图标时,拉入刷新操作才起作用。这不是正确的解决方案,但它对我有效。

这并不能回答问题。嗯。。。据我回忆,设置refreshing={false}可防止视图指示活动刷新。问题是隐藏刷新指示器。这个问题是专门针对Android的,这显然是一个更难的问题。我很感激你花时间打字。