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

app:layout_design_density="1" 这个属性是多少? #3

Open
littleKun opened this issue Nov 10, 2016 · 12 comments
Open

app:layout_design_density="1" 这个属性是多少? #3

littleKun opened this issue Nov 10, 2016 · 12 comments

Comments

@littleKun
Copy link

试用了一下 很不错
这个可以理解为160-->1 320-->2 吗?
因为是int类型的 那么 240呢?
还有这个lib是不是太老了 连你说的一定要加上的三个design属性都没有加上去啊?
还望分享一下最新的lib,谢谢

@gavinliu
Copy link
Owner

readme 太老了,没更新,给我点时间,过段时间更新个完整的。


density的值就是 context.getResources().getDisplayMetrics().density

design_density 就是设计图的 density

比如说设计图是给MX5设计的,那么他的 design_density 就是 MX5 的 context.getResources().getDisplayMetrics().density 的值 等于 3

@littleKun
Copy link
Author

期待最新的版本
谢谢分享

@littleKun
Copy link
Author

还有一个问题 我们拿到的设计图纸都是px作为单位的,直接在布局文件中写dp,这个 我们也不知道啊 难道难道是根据 比如说 12800*800 10.1‘ 这就是mdpi,然后我们就按照1px==1dp 这样写吗?’

@gavinliu
Copy link
Owner

给你们的是px,你就写px就好了,不用自己转换了。

@gavinliu
Copy link
Owner

更新了一版,有任何问题,欢迎反馈。

@littleKun
Copy link
Author

简单试了一下 很不错 谢谢分享

@littleKun
Copy link
Author

注意事项
建议缩放方式 上下滑动的界面按屏幕宽等比缩放
左右滑动的界面按屏幕高等比缩放
请教一下 这个注意事项在哪里变更啊?

@gavinliu
Copy link
Owner

    <attr name="layout_scale_by" format="enum">
        <enum name="width" value="0"/>
        <enum name="height" value="1"/>
    </attr>

@gavinliu
Copy link
Owner

app:layout_scale_by="height"

@littleKun
Copy link
Author

请问在application中配置config时,所填的 Design Density 这个值 目前只能取int类型的,但实际上这个值得到的是float类型的 如果说这个设计值是1.5 或者 1.8之类的 那 会不会影响整个布局呢?

@gavinliu
Copy link
Owner

会,应该算不准了,我马上更新一下。ScaleConfig 类需要改动一下。其实本来存的就是 float,构造方法属性写错了。

@gavinliu
Copy link
Owner

好了

dependencies {
    compile 'cn.gavinliu.android.lib:ScaleLayout:1.0.3'
}
ScaleConfig.create(this, 1080, 1920, 3f, ScaleConfig.DIMENS_UNIT_DP);

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

2 participants