gpt4 book ai didi

css - ScrollView 上的固定按钮

转载 作者:技术小花猫 更新时间:2023-10-29 12:04:47 28 4
gpt4 key购买 nike

我目前正在尝试在屏幕右下角的 ScrollView 上显示一个按钮,但它不起作用。当我 ScrollView 时,按钮会移动。我试着先插入按钮,但 ScrollView 在它上面。

class HomePage extends Component {
loadUserItems() {
this.props.loadUserItems();
}
constructor(props) {
super(props);
this.loadUserItems();
}
render() {
return (
<Container>
<Content>
<Header />
<View>
<ItemSquareDisplay
items={this.props.items && this.props.items.length > 0
? this.props.items
: ''} />
</View>
<Button style={styles.buttonStyle}>
<Text style={styles.buttonTextStyle}>+</Text>
</Button>
</Content>
</Container>
);
}
}
// CONNECTE LES PROPS DE CETTE CLASSE AUX STATES DE REDUX
const mapStateToProps = state => {
return {
items: state.items.items,
};
};
// PERMET A CETTE CLASSE DE LINKER LES PROPS AUX ACTIONS DE REDUX
export default connect(mapStateToProps, {loadUserItems}) ( HomePage );
const styles = {
headerViewStyle : {
alignItems: 'center',
backgroundColor: '#cc003d',
height: 90
},
headerImageStyle : {
height: 80,
width: 250,
resizeMode: 'contain',
marginTop: 7,
},
buttonStyle : {
backgroundColor: '#fc454e',
width: 66,
height: 66,
borderRadius: 33,
justifyContent: 'center',
alignItems:'center',
position: 'absolute',
bottom: 20,
right: 20
},
buttonTextStyle : {
color:'white',
fontSize: 45,
marginBottom: 6
}
}

我试过“固定”位置,但 react-native 不支持它。我希望按钮位于我的元素上方。 Output

但我不希望它在我 ScrollView 时移动。

最佳答案

好的,我明白了:

render() {
return (
<View>
<Header />
<ScrollView>
<View>
<ItemSquareDisplay
items={this.props.items && this.props.items.length > 0
? this.props.items
: ''} />
</View>
</ScrollView>
<Button style={styles.buttonStyle}>
<Text style={styles.buttonTextStyle}>+</Text>
</Button>
</View>
);
}

很明显,我需要从容器组件中提取按钮。谢谢你们的回答。

关于css - ScrollView 上的固定按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49509604/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com