如何在React Native中设计像图片一样的界面

huangapple go评论67阅读模式
英文:

how i do design in React Native like image

问题

I'm new in React Native and i don't know how do this:

如何在React Native中设计像图片一样的界面

How i do for create a component similar to image,
My code is this:

import * as React from 'react';
import { View, Text, StyleSheet } from "react-native";

export default function SeccionA({navigation}) {
    return (
        <View style={styles.contenedor}>
            <View style={styles.listado} >
                <View style={styles.listadoItem}>
                    <Text>BVCC</Text>               
                    <Text>15.709</Text>
                    <Text>2.65</Text>
                    <Text>2%</Text>
                </View>
                <View style={styles.listadoItem}>
                    <Text>IBC</Text>
                </View>
                <View style={styles.listadoItem}>
                    <Text>Industrial</Text>
                </View>
                <View style={styles.listadoItem}>
                    <Text>Financiero</Text>
                </View>
                <View style={styles.listadoItem}>
                    <Text></Text>
                </View>
            </View>        
        </View>
    );
}
   
const styles = StyleSheet.create({
    contenedor: {
        marginHorizontal: 10
    },
    listado: {
        flexDirection: 'row',
        flexWrap: 'wrap',
        justifyContent: 'space-between'
      },
      listadoItem: {
        flexBasis: '49%',
        paddingHorizontal: 30
      },    
});

This is call by initial page like component,

Thanks a lot for your time.

英文:

i'm new in React Native and i don't know how do this:

如何在React Native中设计像图片一样的界面

How i do for create a component similar to image,
My code is this:

import * as React from &#39;react&#39;;
import { View, Text, StyleSheet } from &quot;react-native&quot;;
export default function SeccionA({navigation}) {
return (
&lt;View style={styles.contenedor}&gt;
&lt;View style={styles.listado} &gt;
&lt;View style={styles.listadoItem}&gt;
&lt;Text&gt;BVCC&lt;/Text&gt;               
&lt;Text&gt;15.709&lt;/Text&gt;
&lt;Text&gt;2.65&lt;/Text&gt;
&lt;Text&gt;2%&lt;/Text&gt;
&lt;/View&gt;
&lt;View style={styles.listadoItem}&gt;
&lt;Text&gt;IBC&lt;/Text&gt;
&lt;/View&gt;
&lt;View style={styles.listadoItem}&gt;
&lt;Text&gt;Industrial&lt;/Text&gt;
&lt;/View&gt;
&lt;View style={styles.listadoItem}&gt;
&lt;Text&gt;Financiero&lt;/Text&gt;
&lt;/View&gt;
&lt;View style={styles.listadoItem}&gt;
&lt;Text&gt;&lt;/Text&gt;
&lt;/View&gt;
&lt;/View&gt;        
&lt;/View&gt;
);
}
const styles = StyleSheet.create({
contenedor: {
marginHorizontal: 10
},
listado: {
flexDirection: &#39;row&#39;,
flexWrap: &#39;wrap&#39;,
justifyContent: &#39;space-between&#39;
},
listadoItem: {
flexBasis: &#39;49%&#39;,
paddingHorizontal: 30
},    
});

This is call by initial page like component,

Thanks a lot for your time.

答案1

得分: 1

只需将带有 horizaontal 属性的 ScrollView 放入 TouchableHighlight 对象中:

<ScrollView horizontal>
  <TouchableHighlight
    onPress={() => {
      setWhatTab(0);
    }}
  >
    <Image
      source={require('../img/btnTransadas.png')}
      style={{ padding: 10, height: 27 }}
    />
  </TouchableHighlight>
  <TouchableHighlight
    style={styles.btnCotizar}
    onPress={() => {
      setWhatTab(1);
    }}
  >
    <Image
      source={require('../img/btnBajando.png')}
      style={{ padding: 10, height: 27 }}
    />
  </TouchableHighlight>
  <TouchableHighlight
    style={styles.btnCotizar}
    onPress={() => {
      setWhatTab(2);
    }}
  >
    <Image
      source={require('../img/btnSubiendo.png')}
      style={{ padding: 10, height: 27 }}
    />
  </TouchableHighlight>
  <TouchableHighlight
    style={styles.btnCotizar}
    onPress={() => {
      setWhatTab(3);
    }}
  >
    <Image
      source={require('../img/btnCotizaciones.png')}
      style={{ padding: 10, height: 27 }}
    />
  </TouchableHighlight>
</ScrollView>;
英文:

Just put a ScrollView with props horizaontal and put the text into the TouchableHighlight object

&lt;ScrollView
horizontal
&gt;
&lt;TouchableHighlight 
onPress={ () =&gt; { 
setWhatTab(0);
}
}
&gt;
&lt;Image 
source={require(&#39;../img/btnTransadas.png&#39;)}
style={{padding: 10, height: 27}}
/&gt;
&lt;/TouchableHighlight&gt;                                
&lt;TouchableHighlight 
style={styles.btnCotizar}
onPress={ () =&gt; {
setWhatTab(1);
}
}
&gt;
&lt;Image 
source={require(&#39;../img/btnBajando.png&#39;)}
style={{padding: 10, height: 27}}
/&gt;
&lt;/TouchableHighlight&gt;                                
&lt;TouchableHighlight 
style={styles.btnCotizar}
onPress={ () =&gt; {
setWhatTab(2);
}
} 
&gt;
&lt;Image 
source={require(&#39;../img/btnSubiendo.png&#39;)}
style={{padding: 10, height: 27}}
/&gt;
&lt;/TouchableHighlight&gt;                                
&lt;TouchableHighlight 
style={styles.btnCotizar}
onPress={ () =&gt; {
setWhatTab(3);
}
} 
&gt;
&lt;Image 
source={require(&#39;../img/btnCotizaciones.png&#39;)}
style={{padding: 10, height: 27}}
/&gt;
&lt;/TouchableHighlight&gt;                                
&lt;/ScrollView&gt;

huangapple
  • 本文由 发表于 2023年3月10日 01:27:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75688078.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定