Android 如何在React Native中单击按钮时更新视图元素的大小?
我是React原生编程新手,想问一下如何在点击按钮时更改视图大小。换句话说,如何动态地改变它 这是视图元素:Android 如何在React Native中单击按钮时更新视图元素的大小?,android,ios,react-native,Android,Ios,React Native,我是React原生编程新手,想问一下如何在点击按钮时更改视图大小。换句话说,如何动态地改变它 这是视图元素: <View style={{ height: 350, alignSelf: "stretch", margin: 10 }} /> 我的目标是,在某些按钮上单击,将此height:350更改为height:450 提前感谢。首先在您的状态中保留一个值,然后单击按钮进行更新 例如: this.state = { height:
<View
style={{ height: 350, alignSelf: "stretch", margin: 10 }}
/>
我的目标是,在某些按钮上单击,将此height:350
更改为height:450
提前感谢。首先在您的状态中保留一个值,然后单击按钮进行更新 例如:
this.state = {
height: 350, //your initial value
};
并在按钮单击功能中设置您的值
将此值设置为您的视图
<View style={{ height: this.state.height, alignSelf: "stretch", margin: 10 }}
/>
就这些。。
快乐的编码 非常感谢:)
<View style={{ height: this.state.height, alignSelf: "stretch", margin: 10 }}
/>