2017-04-25 58 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