我正在构建react
material-ui
虚拟(屏幕上)键盘。而且我很难实现关键尺寸的未来。我正在使用FlatButtton
当我使用标签来显示符号键时,我想了一个方法来更改label
的尺寸,但是在使用icon
和SvgIcon
时我还没有找到更改icon
的尺寸的方法。我尝试过label
和labelStyle
,但与文本label
不一样。更改FlatButton图标大小
这是我如何改变label
的大小:
let theme: MuiTheme = getMuiTheme();
theme.button.height += 10;
theme.button.minWidth += 10;
theme.flatButton.fontSize += 10;
return (
<MuiThemeProvider muiTheme={theme}>
<div>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,300,500" rel="stylesheet" type="text/css"/>
<Keyboard
textField={textField}
open={this.state.open}
onRequestClose={this._onRequestClose}
onInput={this._onInput}
layout={[AlphaNumericKeyboard]}
/>
</div>
</MuiThemeProvider>
);
的代码只是用于开发,我的想法时,我所做的就是删除link
和div
,代之以getMuiTheme()
this.context.muiTheme
和+= 10
与= this.props.keySize
。
这是我用来改变icon
的大小不同的代码:
React.cloneElement(icon, {style: {width: 34, height: 34}});
这时候我render
使用的作品时,我render
只是icon
但<FlatButton icon={React.cloneElement(icon, {style: {width: 34, height: 34}})} />;
它总是与大小为24x24 。我已经尝试过theme.button.iconButtonSize += 10;
,但仍然没有结果。
我已经开始浏览material-ui
的源代码,但仍未找到改变尺寸的方法。
这是最后觉得我已经试过,因为我发现,FlatButton剂量变化margin
和padding
和思维空间是远远不够的,但仍有共有42x42空间空的,这个剂量没有帮助...
const noStyl: React.CSSProperties = {
marginLeft: 0,
marginRight: 0,
paddingLeft: 0,
paddingRight: 0
};
keyboardKey = <FlatButton icon={React.cloneElement(icon, {style: {width: 34, height: 34}})} labelStyle={noStyl} />;
那么有没有办法在使用FlatButton
时更改icon
的尺寸?
如果您正在使用SVG的图标,那么很可能'viewBox'属性是你想要的。就拿一看看页面底部的可用svg-icons属性 - http://www.material-ui.com/#/components/svg-icon –
'''viewBox'''只能缩小尺寸(我需要增加尺寸).'''''''''表示图标应该放置在svg元素中的大小,我不想改变这个元素的大小 –
可以通过'viewBox'增加图标的大小,它可以接受四个值:' x1 y1 x2 y2',其中(x1,y1)代表左上角,(x2,y2)代表右下角。 Svg图标本身将在这些坐标之间伸展。默认情况下,该值为'0 0 24 24',以增加您可以使用的图标大小,例如'0 0 36 36'。 –