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

利用项目的适配工具ScreenUtil,为何同样的大小不同写法(ScreenUtil().getHeight 和ScreenUtil.getInstance().getHeight)结果值不一样呢 #18

Closed
zhujinsheng opened this issue Aug 19, 2019 · 9 comments

Comments

@zhujinsheng
Copy link

image

@Sky24n
Copy link
Owner

Sky24n commented Aug 19, 2019

代码贴一下

:octocat: From gitme Android

@zhujinsheng
Copy link
Author

print("默认的尺寸360*640   手机测试是1080 * 1920 的小米note1手机");
print("100 ScreenUtil().getHeight= ${ScreenUtil().getHeight(100)}");
print(
    "100 ScreenUtil.getInstance().height = ${ScreenUtil.getInstance().getHeight(100)}");
print("360 ScreenUtil().getWidth= ${ScreenUtil().getWidth(360)}");
print(
    "360 ScreenUtil.getInstance().getWidth= ${ScreenUtil.getInstance().getWidth(360)}");
print(" ScreenUtil()  == Scwidth = ${ScreenUtil().screenWidth}");
print(
    " ScreenUtil().screenWidth = ${ScreenUtil.getInstance().screenWidth}");

@zhujinsheng
Copy link
Author

我用的是 小米note1进行测试的

@Sky24n
Copy link
Owner

Sky24n commented Aug 20, 2019

只能使用单例ScreenUtil.getInstance().xxx;
ScreenUtil().xxx根本就没有走init,没有获取屏幕参数,并没有适配,而是直接输出原始数据。
另外:
不是很建议使用这个来适配,到处这个也挺麻烦的。合理应用好row,column等基础组件app也能很好适配的。
如果你非要使用这个适配,建议使用宽基准来适配。
或者使用新的适配方法:
double adapterSize = ScreenUtil.getInstance().getAdapterSize(100);
double adapterSize = ScreenUtil.getAdapterSizeCtx(context, 100)

@dxjdqc
Copy link

dxjdqc commented Aug 21, 2019

我用的是 小米note1进行测试的

请问适配问题解决了吗?最后怎么适配的啊? 我用的是
setDesignWHD(360.0, 640.0, density: 3);
ScreenUtil.getInstance().getAdapterSize(15) 这样没法适配

@Sky24n
Copy link
Owner

Sky24n commented Aug 21, 2019

我用的是 小米note1进行测试的

请问适配问题解决了吗?最后怎么适配的啊? 我用的是
setDesignWHD(360.0, 640.0, density: 3);
ScreenUtil.getInstance().getAdapterSize(15) 这样没法适配

具体问题?

@dxjdqc
Copy link

dxjdqc commented Aug 21, 2019

我用的是 小米note1进行测试的

请问适配问题解决了吗?最后怎么适配的啊? 我用的是
setDesignWHD(360.0, 640.0, density: 3);
ScreenUtil.getInstance().getAdapterSize(15) 这样没法适配

具体问题?

不同手机每一屏显示的不一样,我是华为手机,其他机型还没测

@Sky24n
Copy link
Owner

Sky24n commented Aug 22, 2019

我用的是 小米note1进行测试的

请问适配问题解决了吗?最后怎么适配的啊? 我用的是
setDesignWHD(360.0, 640.0, density: 3);
ScreenUtil.getInstance().getAdapterSize(15) 这样没法适配

具体问题?

不同手机每一屏显示的不一样,我是华为手机,其他机型还没测

发下图呢

@zhujinsheng
Copy link
Author

只能使用单例ScreenUtil.getInstance().xxx;
ScreenUtil().xxx根本就没有走init,没有获取屏幕参数,并没有适配,而是直接输出原始数据。
另外:
不是很建议使用这个来适配,到处这个也挺麻烦的。合理应用好row,column等基础组件app也能很好适配的。
如果你非要使用这个适配,建议使用宽基准来适配。
或者使用新的适配方法:
double adapterSize = ScreenUtil.getInstance().getAdapterSize(100);
double adapterSize = ScreenUtil.getAdapterSizeCtx(context, 100)

是的 我也发现宽度适配还可以,根据UI定义的高度就总有差别,

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