Giter Site home page Giter Site logo

Comments (12)

pengyanbing avatar pengyanbing commented on May 19, 2024 2

为什么我调用autoConvertDensity 没有效果?

from androidautosize.

JessYanCoding avatar JessYanCoding commented on May 19, 2024

方案一, 弹出 Toast 之前,调用 AutoSize.autoConvertDensityOfGlobal(Activity),如果 toast 还不能正常显示, 就调用 AutoSize.autoConvertDensityOfGlobal(Activity, size, true),填一个让你的 toast 能正常显示的 size 即可,这个 size 自己尝试,找到一个让这个 toast 显示效果最好的 size 即可

方案二,使用副单位布局,详情查看 demo-subunits

方案三,自定义 Toast

方案四,在弹出 Toast 之前取消适配,调用 AutoSize#cancelAdapt

from androidautosize.

q876625596 avatar q876625596 commented on May 19, 2024

好的,我现在采用的方法是自定义toast,这样就没问题了

from androidautosize.

JessYanCoding avatar JessYanCoding commented on May 19, 2024

ok,一样的效果

from androidautosize.

fmliqi avatar fmliqi commented on May 19, 2024

方案一, 弹出 toast 之前,调用 AutoSize.autoConvertDensityOfGlobal(Activity),如果 toast 还不能正常显示, 就调用 AutoSize.autoConvertDensityOfGlobal(Activity, size, true),填一个让你的 toast 能正常显示的 size 即可,这个 size 自己尝试,找到一个让这个 toast 显示效果最好的 size 即可

方案二,使用副单位布局,详情查看 demo-subunits

---reply,你没有提到在弹出Toast之前取消适配,然后弹出之后再适配,这样写一个工具方法不是更好吗。你这个方案一我感觉要对不同的dpi手机都有不同的调整值,是不是更不好弄?

from androidautosize.

JessYanCoding avatar JessYanCoding commented on May 19, 2024

@yungelee 你提到的这个只是某些文章的解决方案,他解决这个问题的方式,就是不让 Toast 进行百分比适配,当然也是可以的,虽然步骤麻烦点,我的方式是让这个问题得到解决,并且可以让 Toast 参与百分比适配,看了你最后一句话,可能你对今日头条的原理不是很理解,你担心根本没有必要,建议你看看我的这篇 文章,里面也提到了为什么系统控件和三方库会在修改 density 出现适配不正常的问题,根本原因在于这些控件的设计图尺寸和自身项目的设计图尺寸不匹配,这是其他所有文章中都未提到的,取消适配只是回避了这个问题

from androidautosize.

fmliqi avatar fmliqi commented on May 19, 2024

@yungelee 你提到的这个只是某些文章的解决方案,他解决这个问题的方式,就是不让 Toast 进行百分比适配,当然也是可以的,我的方式是让这个问题解决,并且可以让 Toast 参与百分比适配,看了你最后一句话,可能你对今日头条的原理不是很理解,建议你看看我的这篇 文章,里面也提到了为什么系统控件和三方库会在修改 density 出现适配不正常的问题,根本原因在于这些控件的设计图尺寸和自身项目的设计图尺寸不匹配,这是其他所有文章中都没提到的

  • 哦我明白了你的意思了。但是今日头条的基本原理我还是懂了,确实很有想法。只不过这里我弹出toast的时候在默认dsty是3的华为手机上没有问题,但是在nexus5x dsty的Toast会变大,我就想这两个系统的控件设计图尺寸应该是不一样。所以如果要适配Toast你的方案一的意思应该是要更改设计图和系统一致吧。如果一个是1000dp,一个是800dp,你就要调整两次吧。是这么理解吗?

from androidautosize.

JessYanCoding avatar JessYanCoding commented on May 19, 2024

如果是系统控件的设计图尺寸都在不同系统上都会变化,那我们必须固定这个系统控件的设计图尺寸不变了,不然我们可能就要 if else 根据不同的系统调整设计图尺寸,这明显太繁琐

解决方案就是自定义 Toast,设计图你来统一,其次就是 show() 前取消适配 AutoSize#cancelAdapt,不过在 AndroidAutoSize 中,取消适配后不需要再重新适配

from androidautosize.

JunWeiAndroid avatar JunWeiAndroid commented on May 19, 2024

如果是系统控件的设计图尺寸都在不同系统上都会变化,那我们必须固定这个系统控件的设计图尺寸不变了,不然我们可能就要 if else 根据不同的系统调整设计图尺寸,这明显太繁琐

解决方案就是自定义 Toast,设计图你来统一,其次就是 show() 前取消适配 AutoSize#cancelAdapt,不过在 AndroidAutoSize 中,取消适配后不需要再重新适配

请问,取消适配后不需要再重新适配,是什么意思

from androidautosize.

qinweiforandroid avatar qinweiforandroid commented on May 19, 2024

方案一, 弹出 Toast 之前,调用 AutoSize.autoConvertDensityOfGlobal(Activity),如果 toast 还不能正常显示, 就调用 AutoSize.autoConvertDensityOfGlobal(Activity, size, true),填一个让你的 toast 能正常显示的 size 即可,这个 size 自己尝试,找到一个让这个 toast 显示效果最好的 size 即可

方案二,使用副单位布局,详情查看 demo-subunits

方案三,自定义 Toast

方案四,在弹出 Toast 之前取消适配,调用 AutoSize#cancelAdapt


大多数时候使用Toast都会封装个工具类用的application的context 但是框架里面需要传个Activity,这个怎么破
@JessYanCoding

from androidautosize.

mysiga avatar mysiga commented on May 19, 2024

调用 AutoSize#cancelAdapt解决,调用AutoSize#cancelAdapt的时机一定要靠前,不要在马上调用show()之前。

from androidautosize.

JunWeiAndroid avatar JunWeiAndroid commented on May 19, 2024

from androidautosize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.