下拉式选择器放置在scrollview iss ins inss ins scroll上,但scrollview是

发布于 2025-02-02 16:05:27 字数 3340 浏览 3 评论 0原文

我已经将下拉式选择器放在滚动视图上方时,当下拉列表选择器和scrollview都被数据播放时,我试图在下拉列表中滚动浏览数据,而是在后台滚动scrollview。 实际上,下拉列表根本没有滚动,即使背景中没有ScrollView,我也不确定我在做什么错。

 <View style={styles.lowerContainer}>
    {sevaListDrop ? (
      <>
        <View // specific search section
          style={[styles.searchContainer, {zIndex: 2, marginBottom: '2%'}]}>
          <DropDownPicker // dropdown
            style={{borderColor: '#ccc'}}
            containerStyle={{flex: 3, marginLeft: '2%'}}
            dropDownContainerStyle={{
              borderColor: '#ccc',
              zIndex: 1000,
              elevation: 1000,
              position: 'absolute',
            }}
            open={openDrop}
            setOpen={setOpenDrop}
            items={sevaListDrop?.map(item => ({
              label: item.sevaName,
              value: item.calendarId,
            }))}
            placeholder="Select Seva"
            value={calendarId}
            setValue={type => setCalendarId(type)}
          />

          <PrimaryButton // search button
            name="Search"
            action={search}
          />
        </View>
        <View // lower container for seva list
          style={[styles.lowerContainer, {justifyContent: 'center'}]}>
          {sevaList ? (
            <ScrollView // seva list
              style={{width: '100%'}}
              contentContainerStyle={{
                alignItems: 'center',
                paddingBottom: 50,
              }}
              showsVerticalScrollIndicator={false}>
              {sevaList?.map((item, index) => (
                <SevaCard // seva card
                  key={index}
                  sevakName={item.sevakName}
                  bookedBy={item.bookedBy}
                  noOfAttendees={item.noOfAttendees}
                  onChangeText={text => {
                    setPeopleCount(item.slotId, text);
                  }}
                  onPress={() =>
                    updateAttendees(item.slotId, item.calendarId)
                  }
                />
              ))}
            </ScrollView>
          ) : noDataInner ? (
            <CautionSection // no data container
              title="No Data Found"
              icon="no_user_found"
            />
          ) : (
            <CautionSection // default container
              title="Search Patron Id"
              icon="search"
            />
          )}
        </View>
      </>
    ) : (
      <View // lower caution container
        style={[styles.lowerContainer, {justifyContent: 'center'}]}>
        {noData ? (
          <CautionSection // no data container
            title="No Data Found"
            icon="no_user_found"
          />
        ) : noConnection ? (
          <CautionSection // no connection container
            title="No Connection"
            icon="no_connection"
          />
        ) : (
          <CautionSection // default container
            title="Search Patron Id"
            icon="search"
          />
        )}
      </View>
    )}
  </View>

 

I have placed a Dropdown picker above a ScrollView, when both Dropdown picker and ScrollView is poppulated with data and I'm trying to scroll through the data in Dropdown it instead scrolling the ScrollView in the background.
Infact the Dropdown isn't scrolling at all, even if there's no ScrollView in the background, I'm not sure what I'm doing wrong.

enter image description here

 <View style={styles.lowerContainer}>
    {sevaListDrop ? (
      <>
        <View // specific search section
          style={[styles.searchContainer, {zIndex: 2, marginBottom: '2%'}]}>
          <DropDownPicker // dropdown
            style={{borderColor: '#ccc'}}
            containerStyle={{flex: 3, marginLeft: '2%'}}
            dropDownContainerStyle={{
              borderColor: '#ccc',
              zIndex: 1000,
              elevation: 1000,
              position: 'absolute',
            }}
            open={openDrop}
            setOpen={setOpenDrop}
            items={sevaListDrop?.map(item => ({
              label: item.sevaName,
              value: item.calendarId,
            }))}
            placeholder="Select Seva"
            value={calendarId}
            setValue={type => setCalendarId(type)}
          />

          <PrimaryButton // search button
            name="Search"
            action={search}
          />
        </View>
        <View // lower container for seva list
          style={[styles.lowerContainer, {justifyContent: 'center'}]}>
          {sevaList ? (
            <ScrollView // seva list
              style={{width: '100%'}}
              contentContainerStyle={{
                alignItems: 'center',
                paddingBottom: 50,
              }}
              showsVerticalScrollIndicator={false}>
              {sevaList?.map((item, index) => (
                <SevaCard // seva card
                  key={index}
                  sevakName={item.sevakName}
                  bookedBy={item.bookedBy}
                  noOfAttendees={item.noOfAttendees}
                  onChangeText={text => {
                    setPeopleCount(item.slotId, text);
                  }}
                  onPress={() =>
                    updateAttendees(item.slotId, item.calendarId)
                  }
                />
              ))}
            </ScrollView>
          ) : noDataInner ? (
            <CautionSection // no data container
              title="No Data Found"
              icon="no_user_found"
            />
          ) : (
            <CautionSection // default container
              title="Search Patron Id"
              icon="search"
            />
          )}
        </View>
      </>
    ) : (
      <View // lower caution container
        style={[styles.lowerContainer, {justifyContent: 'center'}]}>
        {noData ? (
          <CautionSection // no data container
            title="No Data Found"
            icon="no_user_found"
          />
        ) : noConnection ? (
          <CautionSection // no connection container
            title="No Connection"
            icon="no_connection"
          />
        ) : (
          <CautionSection // default container
            title="Search Patron Id"
            icon="search"
          />
        )}
      </View>
    )}
  </View>

 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枕花眠 2025-02-09 16:05:27

真正引起此问题的是zindex:2&lt; view&gt;中//特定的搜索部分。如果删除zindex,则应停止遇到此问题。

同时,您可能会在下拉列表中遇到问题,因为您将不再看到选项(或下拉列表本身)。要解决此问题,您应该拥有&lt; view // seva List组件的下部容器&lt; view //特定搜索部分 component,然后添加zindex:0在最后一个&lt; view&gt;喜欢的情况下:

<View> // specific search section
    <DropdownPicker zIndex={1000}></DropdownPicker>
    <PrimaryButton></PrimaryButton>
    <View style={{zIndex:0}}>
        <ScrollView>
            <SevaCard></SevaCard>
        </ScrollView>
    </View>
</View>

如您所见,我还添加了zindex作为元素的属性,因为它可以在下拉点中允许,并首选。

What is really causing this problem is the zIndex:2 in the <View> // specific search section. If you erase that zIndex you should stop having this problem.

At the same time, you may have a problem with your Dropdown, because you will not see the options anymore (or the Dropdown itself). To solve this you should have your <View // lower container for seva list component inside your <View // specific search section component, and then add a zIndex:0 in that last <View> like this:

<View> // specific search section
    <DropdownPicker zIndex={1000}></DropdownPicker>
    <PrimaryButton></PrimaryButton>
    <View style={{zIndex:0}}>
        <ScrollView>
            <SevaCard></SevaCard>
        </ScrollView>
    </View>
</View>

As you can see, I also added a zIndex as an attribute of the element, since it is allowed in DropdownPicker, and preferred.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文