-
Notifications
You must be signed in to change notification settings - Fork 496
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
It seems a bug, when you use sp in some special devices such as iPad. #180
Comments
The use of px for adaptation may indeed cause the problem you mentioned. In fact, I have considered using dp as the unit, but the size of the design draft can be set to dp, and px is more versatile, and some do not support dp, so I Delayed the plan. My current experience is to try not to limit the size of the text, it may be helpful Regarding your suggestion, I actually said: If you want a square, it is recommended to use setWidth for both width and height. |
Emmm... I wanna to get a perfect solution of sp() . I've already implemented the function getRadius(). And I think, we should use the min of adapted height and adapted width, otherwise, it'll be overflowed on some devices. |
you can try that: v4.0.1
and I will add radius method on 4.0.2 |
Descriptions:
In general, a textview with 22sp text content, may be 30dp height in screen. But, when you put the textview into a constraint container which is 30dp height, the textview will be overflow.
It means, the value return of sp() function may be bigger in pads.
Devices:
Some abnormal screen rate devices, especially iPad.
Configs:
ScreenUtil.init(context, width: 375, height: 812, allowFontScaling: false);
Suggestions:
Further, i have a suggestion. Could you please give a public api such as getRadius(). We want to use it in some special cases, such as square widgets, or other round widgets.
A common scenario as i say, here is a square widget with a 16 side length. If i set ScreenUtil().setWidth(16) to the widget width, and in turn, i set ScreenUtil().setHeight(16) to the widget height. When the widget displayed on ipad screens, it will not be a square widget no more. It will become a rectangle widget because of the difference of height & width.
The implementation of getRadius() may be easy, you can get it from the min of adapted height and adapted width.
static num radius(num r) => min(ScreenUtil().setWidth(r), ScreenUtil().setHeight(r));
The text was updated successfully, but these errors were encountered: