React native 如何垂直对齐本地列表中的图标。项?
我正在使用react本地论文的List.Item组件 我有以下代码:React native 如何垂直对齐本地列表中的图标。项?,react-native,expo,react-native-paper,React Native,Expo,React Native Paper,我正在使用react本地论文的List.Item组件 我有以下代码: <List.Item title={<FirstNameInput />} right={props => <List.Icon {...props} icon="pencil" />} style={{ backgroundColor:
<List.Item
title={<FirstNameInput />}
right={props => <List.Icon {...props} icon="pencil" />}
style={{ backgroundColor: customTheme.colors.background, justifyContent: 'center' }}
/>
}
style={{backgroundColor:customTheme.colors.background,justifyContent:'center'}
/>
但图标仍然位于顶部。无论
标题的高度如何,如何使其保持垂直对齐?您可以使用flex对齐列表。项目:
}
风格={{
backgroundColor:customTheme.colors.background,
为内容辩护:“中心”,
对齐自我:“中心”,
对齐项目:'中心',
}}
/>
制作列表的唯一方法。垂直居中的图标是在列表中传递margintical。图标样式
您必须通过marginstical:hight/2-offset
您需要设置偏移量,因为标题使用的是margintical:6
由于标题,左右样式由
const ListItemHeight=300;
常数偏移=12;
返回(
}
风格={{
背景颜色:“红色”,
宽度:“100%”,
高度:ListItemHeight
}}
/>
);
const ListItemHeight=300;
const offset=12;
return (
<List.Item
title={"ABC"}
right={props => <List.Icon {...props} style={{marginVertical:ListItemHeight/2-offset}} icon="pencil" />}
style={{
backgroundColor: "red",
width:"100%",
height:ListItemHeight
}}
/>
);