React Native dropDown Menu не может быть нажата - PullRequest
0 голосов
/ 14 февраля 2019

У меня есть меню dropDown, в котором нужно щелкнуть, но когда я щелкаю его элементы, щелкают базовые элементы, которые представляют собой панель поиска и плоский список, который также можно нажимать.Я хочу, чтобы щелкнуло меню, а не панель поиска или плоский список.что мне делать?

Вот скриншот моего симулятора:

enter image description here

Я не могу нажать на «Арабский» и «Персидский "в меню.

Вот части моего кода:

import React, { Component } from 'react';
import {StyleSheet, Text, View, FlatList, TouchableOpacity } from 'react-native';
import { List, ListItem, SearchBar } from 'react-native-elements';
import DropdownMenu from 'react-native-dropdown-menu';
import {Header, Left, Right, Icon} from 'native-base'

var SQLite = require('react-native-sqlite-storage')
var db = SQLite.openDatabase({name: 'test.sqlite', createFromLocation: '~dictionary.sqlite'})
var data = [["English", "Arabic", "Persian"]];

export default class App extends Component {
  constructor(props) {
    super(props)
    ...
    db.transaction((tx) => {
      ... 
      }

 searchFilterFunction = text => {
    ...
  };


  render() {
    return (
      <View style = {styles.container}>
        <Header style={styles.headerStyle}>
          ...
        </Header>
        <View style={{height: 3 }}/>
        <View style={styles.menuView}>
          <DropdownMenu
            bgColor={"#B38687"}
            activityTintColor={'green'}
            titleStyle={{color: '#333333'}} 
            zIndex={100} 
            handler={(selection, row) => this.setState({text4: data[selection][row]})}
            data={data}
            >
          </DropdownMenu>
          <Icon name="arrow-round-forward" style={styles.iconStyle}/>
          <DropdownMenu
            bgColor={"#B38687"}
            activityTintColor={'green'}
            titleStyle={{color: '#333333'}}
            zIndex={100} 
            handler={(selection, row) => this.setState({text: data[selection][row]})}
            data={data}
            >
          </DropdownMenu>
        </View >
        <View >
          <View style={styles.viewBorder}>
            <SearchBar
              ...
              />
          </View>
          <View style={styles.viewBorder}>
            <List containerStyle={{ flexDirection: 'column-reverse', borderTopWidth: 0, borderBottomWidth: 0 }} >
              <FlatList 
                ...
                onPress={() =>{this.props.navigation.navigate('Meaning', {data: (item.word_english +'\n' + item.word_arabic)} ); }}
                    ...
                  /> )}
                />
              </List>
            </View>
          </View>
       </View>);}
          }

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#CBEFDD',
    // flexDirection: 'column'
  },
  iconStyle:{
    backgroundColor:'#CBEFDD',
    color:'#84B071',
    marginLeft: '5%',
    marginRight: '5%',
    marginTop: 7,
    // height:30,
    // alignContent:'center'
    },
  menuView:{
    // flex:1, 
    // height: 50,
    marginLeft: 3,
    marginRight: 3,
    flexDirection:'row',
    zIndex:100,
    },
  rezvanText:{
    flex:1 ,
    fontSize: 20, 
    color: 'white',
    justifyContent:'flex-end'
    },
  headerStyle:{
    backgroundColor : "#84B071"
    },
  viewBorder: {
    backgroundColor: 'white',
    borderWidth: 2, 
    borderColor: '#B38687', 
    marginVertical:3, 
    marginLeft: 3, 
    marginRight: 3
  }


});

1 Ответ

0 голосов
/ 14 февраля 2019

Благодаря Эндрю и это Я мог решить проблему, я поставил ответ, если кому-то это нужно!

Решение состоит в том, чтобы назначить minHeight представлению, содержащемуDropDown меню, а также назначить ему position: 'absolute'.Затем установите ограничения, чтобы они не перекрывались, и вуаля! .. Я публикую здесь стили:

const styles = StyleSheet.create({
  container: {
    ...
  },
  iconStyle:{
    ...
    },
  menuView:{
    // flex:1, 
    // height: 50,
    **minHeight:215,**
    marginLeft: 3,
    marginRight: 3,
    marginTop:60,
    flexDirection:'row',
    zIndex:100,
    **position: 'absolute'**
    },
  rezvanText:{
    ...
    },
  headerStyle:{
    ...
    },
  searchBarView: {
    backgroundColor: 'white',
    borderWidth: 2, 
    borderColor: '#B38687', 
    **marginTop:51,** 
    marginLeft: 3, 
    marginRight: 3
  },
  flatListVew:{
    backgroundColor: 'white',
    borderWidth: 2, 
    borderColor: '#B38687', 
    marginVertical:3, 
    marginLeft: 3, 
    marginRight: 3
  }


});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...