我正在構建一個反應本機應用程序(直到現在還沒有iOS開發經驗),我正在努力正確佈置。屏幕應該是這樣的:造型反應原生組件 - 當以像素定義時,一切都太大
我設置頁邊距的像素大小我之後,但他們似乎太大了。我是否誤解了原生布局的反應方式?
代碼這個組件:
import React, { Component, PropTypes } from 'react';
import {
Text,
View,
Button,
Image,
TouchableHighlight,
StyleSheet
} from 'react-native'
import Background from '../assets/background.png'
import SoundOn from '../assets/main_icon_sound.png'
import SoundOff from '../assets/main_icon_soundoff.png'
import imprintButton from '../assets/main_icon_imprint.png'
import storyButton from '../assets/main_icon_story.png'
import gameButton from '../assets/main_icon_game.png'
import Game from './Game'
import Imprint from './Imprint'
import Story from './Story'
import Sound from './Sound'
const styles = StyleSheet.create({
background: {
height: 700, width: 700
},
soundButton: {
marginLeft: 60, marginTop: 40
},
imprintButton: {
marginLeft: 60, marginTop: 40
},
storyButton: {
marginLeft: 382, marginBottom: 89
},
gameButton: {
marginRight: 382, marginBottom: 89
}
})
class MainMenu extends Component {
static propTypes = {
navigator: PropTypes.object.isRequired,
}
render() {
return (
<View>
<Image source={Background} resizeMode={Image.resizeMode.contain} style={styles.background}>
<View style={{backgroundColor: 'rgba(0,0,0,0)'}}>
<TouchableHighlight style={styles.soundButton}>
<Image source={SoundOn} resizeMode={Image.resizeMode.contain}></Image>
</TouchableHighlight>
<TouchableHighlight style={styles.imprintButton}>
<Image source={imprintButton}></Image>
</TouchableHighlight>
<TouchableHighlight style={styles.storyButton}>
<Image source={storyButton}></Image>
</TouchableHighlight>
<TouchableHighlight style={styles.gameButton}>
<Image source={gameButton}></Image>
</TouchableHighlight>
</View>
</Image>
</View>
)
}
}
export default MainMenu
是否有可能共享使用最少的代碼複製這個代碼庫? – Andreyco
@Andreyco肯定我已經啓動了項目,因爲它只有一個重要的組件:https://github.com/tomchambers2/graublaumiau – Tom