2017-04-25 65 views
0

我在视图中的布局中挣扎。我试图在蓝色视图的左侧放置随机图片(本例中为星巴克徽标)。我希望它与左边界对齐。无论我用什么布局属性,它都不会像我所期望的那样工作。在视图中放置图像

logoStyle:{ 
    width: 210, 
    height: 120, 
    left: 0, 
    resizeMode: 'contain', 
    backgroundColor: 'blue', 

    }, 

Here is how it looks

回答

0

你想要把图像徽标的后台视图左侧。这里的例子:

 render() { 
      <View style={{flex: 1, backgroundColor: 'blue'}}> 
       <View style={{ flexDirection: 'row', 
        alignItems: 'flex-start', justifyContent: 'flex-start'}} > 
        <Image style={{width: 20, height: 20}} /> 
       </View> 
      </View> 
     } 

你可以试试!

欢呼!

+0

嘿谢谢你的回复!我按照你的建议做了它,但仍然没有将标志移到左侧。我把标志放在flex属性的视图中并应用样式。 – misi06

+0

logoStyle:{ 宽度:210, 高度:120, resizeMode: '包含', flexDirection: '行', alignItems: '柔性开始', justifyContent: '柔性开始', 的backgroundColor:'透明', } – misi06

+0

我编辑了我的答案,请试试! @ misi06 – johnny