0

I tried to overlap an image on Appbar Component and it's not happening.

Here is my code...

<View style={{flex: 1, backgroundColor: '#F6F8FB'}}>
        <Appbar.Header style={styles.appHeader}>
          <Appbar.BackAction />
        </Appbar.Header>
        <Image
          source={require('../../../resource/images/LivingRoom.png')}
          style={styles.imageStyle}
        />
</View>

Here is the CSS for the same.

  appHeader: {
    backgroundColor: '#184DB8',
    height: (15 / 100) * height,
    width: '100%',
    alignItems: 'flex-start',
  },
  imageStyle: {
    width: '100%',
    height: (25 / 100) * height,
    borderTopLeftRadius: 50,
    borderTopRightRadius: 40,
  },

I need Help!!

enter image description here

Like this Image

Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43
Satyam
  • 567
  • 1
  • 6
  • 20

3 Answers3

0

Try to add postion:'absolute to imageStyle.

imageStyle: {
    postion: 'absolute',
    top: 0,
    left: 0,
    width: '100%',
    height: (25 / 100) * height,
    borderTopLeftRadius: 50,
    borderTopRightRadius: 40,
  },

now you can play with image position by edit top.

Dharman
  • 30,962
  • 25
  • 85
  • 135
asaeed
  • 21
  • 3
0

Write </Appbar.Header> after the <Image> tag

<View style={{flex: 1, backgroundColor: '#F6F8FB'}}>
        <Appbar.Header style={styles.appHeader}>
            <Appbar.BackAction />
            <Image
               source={require('../../../resource/images/LivingRoom.png')}
               style={styles.imageStyle}
            />
       </Appbar.Header>

</View>
Dharman
  • 30,962
  • 25
  • 85
  • 135
Elif
  • 141
  • 13
0

I have solved your problem by removing "flex: 1" from your view container. The result I got was the following:

Example

This is the code:

<View style={styles.header}>
  <Appbar.Header style={styles.appHeader}>
    <Appbar.BackAction />
  </Appbar.Header>
  <Image
    source={require('../../assets/room.jpg')}
    style={styles.imageStyle}
  />
</View>

And the styles:

  header: {
    flex: 0,
    backgroundColor: '#184DB8',
    shadowColor: 'transparent',
  },
  appHeader: {
    flex: 0,
    backgroundColor: '#184DB8',
    width: '100%',
    alignItems: 'flex-start',
    borderBottomWidth: 0,
    shadowColor: 'transparent',
  },
  imageStyle: {
    flex: 0,
    width: '100%',
    borderTopLeftRadius: 50,
    borderTopRightRadius: 40,
  }

(PS: sorry if my English writing is somewhat confusing, I'm learning it) (PS2: I am new to the world of react and I couldn't remove the shadow that the header has, an apology)