React Native 中的主体变得可滚动

发布于 2025-01-09 14:24:26 字数 1602 浏览 4 评论 0原文

我对滚动视图有一个小问题。

我希望标题变得粘性,标题后面意味着消息正文变得可滚动。

输入图片这里的描述

我已经尝试过以下一种实现方式。

HelpComponentContainer:---

 <View style={{ height: "100%" }}>
            <ScrollView
              style={{ flexGrow: 0 }}
            >
              <View>
                <Title>{messageTitle}</Title>

                <MessageBody>{messageBody}</MessageBody>
              </View>
            </ScrollView>
          </View>
const MessageBody = styled(Text)`
  color: #2d3e58;
  text-align: right;
  align-self: center;
  width: 90%;
`;

中使用这个组件

我在message-widget-card

 <RBSheet
        ref={helpSheet}
        closeOnDragDown={true}
        closeOnPressMask={true}
        height={hp(60)}
        customStyles={{
          wrapper: {
            backgroundColor: "rgba(52,52,52,0.8)",
          },
          draggableIcon: {
            backgroundColor: "#d3d6dc",
          },
          container: {
            borderRadius: 15,
          },
        }}
      >
        <Container>
          <HelpComponentContainer
            isHelpForMessage={true}
            messageTitle={helpMessageTitle}
            messageBody={helpMessage}
          />
        </Container>
      </RBSheet>

:--我已经尝试过这个。

但卷轴不起作用。

只是我希望蓝色标题应该是粘性的并且正文可以滚动。

我该如何解决这个问题?

谢谢!!

i have small issue with scrollview.

i want to the title become sticky and the after the title means the messageBody become scrollable.

enter image description here

i have tried below one for this implementation.

HelpComponentContainer:---

 <View style={{ height: "100%" }}>
            <ScrollView
              style={{ flexGrow: 0 }}
            >
              <View>
                <Title>{messageTitle}</Title>

                <MessageBody>{messageBody}</MessageBody>
              </View>
            </ScrollView>
          </View>
const MessageBody = styled(Text)`
  color: #2d3e58;
  text-align: right;
  align-self: center;
  width: 90%;
`;

i am using this component in

message-widget-card:--

 <RBSheet
        ref={helpSheet}
        closeOnDragDown={true}
        closeOnPressMask={true}
        height={hp(60)}
        customStyles={{
          wrapper: {
            backgroundColor: "rgba(52,52,52,0.8)",
          },
          draggableIcon: {
            backgroundColor: "#d3d6dc",
          },
          container: {
            borderRadius: 15,
          },
        }}
      >
        <Container>
          <HelpComponentContainer
            isHelpForMessage={true}
            messageTitle={helpMessageTitle}
            messageBody={helpMessage}
          />
        </Container>
      </RBSheet>

i have tried this one.

But the scroll is not working.

just i want the Blue color title should be sticky and the body become scrollable.

How can i resolve this issue?

Thanks!!

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

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

发布评论

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

评论(1

又怨 2025-01-16 14:24:26

尝试像这样实现将标题保留在 ScrollView 之外。

const HelpComponentContainer = () => {
  return (
    <View style={{flex: 1}}>
      <Title>{messageTitle}</Title>
      <ScrollView style={{flex: 1}}>
        <MessageBody>{messageBody}</MessageBody>
      </ScrollView>
    </View>
  );
};

export default HelpComponentContainer;

Try to implement like this keep the title outside ScrollView.

const HelpComponentContainer = () => {
  return (
    <View style={{flex: 1}}>
      <Title>{messageTitle}</Title>
      <ScrollView style={{flex: 1}}>
        <MessageBody>{messageBody}</MessageBody>
      </ScrollView>
    </View>
  );
};

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