Adi*_*jaz 2 javascript android reactjs react-native react-native-paper
嘿!我是 React Native 开发和使用 expo-cli 的新手。我在我的应用程序中添加了一个react-native-paper数据表,它工作正常,但我有很多字段,我想在水平方向滚动屏幕,但我不明白该由谁来做。请向我建议我可以为这个问题做些什么。
import React from 'react';
import { StyleSheet, Text, View, ScrollView, TextInput, Button, } from 'react-native';
import { Card } from "react-native-shadow-cards";
import {DataTable} from "react-native-paper"
const AllUsers = () =>{
return(
<View>
<View style={styles.headSection}>
<Text style={styles.titleHeading}>All Users</Text>
</View>
<ScrollView horizontal>
<DataTable style={styles.table} >
<DataTable.Header>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading}>Id</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Username</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >First Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Last Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Email</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >First Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Last Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Email</Text></DataTable.Title>
</DataTable.Header>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>adilijaz.02@gmail.com</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>adilijaz.02@gmail.com</DataTable.Cell>
</DataTable.Row>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>adilijaz.02@gmail.com</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>adilijaz.02@gmail.com</DataTable.Cell>
</DataTable.Row>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>adilijaz.02@gmail.com</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>adilijaz.02@gmail.com</DataTable.Cell>
</DataTable.Row>
<DataTable.Pagination
page={1}
numberOfPages={3}
onPageChange={(page) => { console.log(page); }}
label="1-2 of 6"
/>
</DataTable>
</ScrollView>
</View>
)
}
const styles = StyleSheet.create({
table:{
},
headSection:{
borderBottomWidth:2,
borderColor:'black',
paddingBottom:15,
},
titleHeading:{
marginTop:50,
fontWeight:'bold',
marginHorizontal:167,
},
tableHeading:{
fontWeight:'bold',
color:'black',
},
header:{
paddingLeft:0,
},
});
export default AllUsers;
Run Code Online (Sandbox Code Playgroud)
要启用水平滚动,您可以将要滚动的内容放在 ScrollView 组件中,并使用 Horizontal 作为 prop,如下所示:
<ScrollView horizontal>
<DataTable style={styles.table} >
<DataTable.Header>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading}>Id</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Username</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Email</Text></DataTable.Title>
</DataTable.Header>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>adilijaz.02@gmail.com</DataTable.Cell>
</DataTable.Row>
<DataTable.Row>
<DataTable.Cell>2.</DataTable.Cell>
<DataTable.Cell>adil09</DataTable.Cell>
<DataTable.Cell>adili09@gmail.com</DataTable.Cell>
</DataTable.Row>
<DataTable.Pagination
page={1}
numberOfPages={3}
onPageChange={(page) => { console.log(page); }}
label="1-2 of 6"
/>
</DataTable>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6411 次 |
| 最近记录: |