Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文字的高度和宽度没有按比例缩放 #34

Closed
danieldai opened this issue Apr 29, 2019 · 5 comments
Closed

文字的高度和宽度没有按比例缩放 #34

danieldai opened this issue Apr 29, 2019 · 5 comments

Comments

@danieldai
Copy link

我有一个布局需要在不同的手机上保持布局的比例,元素的高度和宽度都是用setWidth设置的,这在大部分元素上工作正常,但是当涉及到文字字体时,出了点问题。

例如下面这段代码,在Android 1080x1920手机上显示正常,但是在 Android 1440x2960手机上,文字的底部显示不出来。(“五”字底部的那一横被截掉)

Container(
    height: screenUtil.setWidth(50),
    child:  Text(
      "周五",
      style: TextStyle(color: color, fontSize: screenUtil.setSp(45)))
)
@lizhuoyuan
Copy link
Collaborator

lizhuoyuan commented Apr 30, 2019

是不是有字体缩放之类的东西?
然后如果只有一个text我觉得还是不要给定高度了

@danieldai
Copy link
Author

danieldai commented Apr 30, 2019

我检查了,不是字体缩放的原因。嗯,确实如果只有一个text比较好处理,我的情况有点复杂,在一列有多个元素需要布局,需要精确控制每个元素的高度

OK

@lizhuoyuan
Copy link
Collaborator

暂时想不到原因

@cixiu
Copy link

cixiu commented May 3, 2019

 Container(
    height: screenUtil.setWidth(50),
    child:  Text(
      "周五",
      strutStyle: StrutStyle(
            forceStrutHeight: true,
            fontSize: ScreenUtil().setSp(45),
          ),
      style: TextStyle(color: color, fontSize: screenUtil.setSp(45)))
)

强制控制字体的高度应该可以解决你的问题 @danieldai

@danieldai
Copy link
Author

@cixiu 非常感谢,我试一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants