react native fixed position code example

Example 1: how to position View absolute react native

<View style={{position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, justifyContent: 'center', alignItems: 'center'}}>
  <Text>Centered text</Text>
</View>

Example 2: make a fixed list in react native

export default function App() {
  const [enteredGoal,setEnteredGoal] = useState('');
  const [courseGoals, setCourseGoals] = useState([]);
  const goalInputHandler = (enteredText) => {
    setEnteredGoal(enteredText);
  }
  const addGoalHandler = () => {
    setCourseGoals(currentGoals => 
      [...currentGoals,enteredGoal]
    )
  }

  return (
    <View style={styles.screen}>
      <View>
        <View style={styles.otherview}>
          <TextInput 
          placeholder='A goal' 
          style={styles.textinput} 
          onChangeText={goalInputHandler} 
          value={enteredGoal}/>
          <Button title='Add' onPress={addGoalHandler}/>
        </View>
      </View>
        <ScrollView>
          {courseGoals.map((goal) => 
            <View key={goal} style={styles.listItem}>
              <Text>{goal}</Text>
            </View>)
          }
        </ScrollView>
	</View>

Example 3: react native scrollbar position issue

scrollIndicatorInsets={{ right: 1 }}

Example 4: react native scrollview fixed header

if (!NativeModules.F8Scrolling) {
  var distance = EMPTY_CELL_HEIGHT - this.state.stickyHeaderHeight;
  var translateY = 0; this.state.anim.interpolate({
    inputRange: [0, distance],
    outputRange: [distance, 0],
    extrapolateRight: 'clamp',
  });
  transform = [{translateY}];
}

Tags:

Html Example