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

Compose 没有效果 #457

Open
5 tasks done
louie-wh opened this issue Dec 11, 2023 · 0 comments
Open
5 tasks done

Compose 没有效果 #457

louie-wh opened this issue Dec 11, 2023 · 0 comments

Comments

@louie-wh
Copy link

Environment

  • Autosize Version: v1.2.1
  • Target Android Version: Android9.0
  • Device Model: 华为WGR-W09
  • Device Resolution: 2560x1600
  • Design Size On AndroidManifest: 1920 1080

Bug Description:

App 架构为单Activity 多Fragment + Compose 架构,
原生View 有缩放效果,Compose 没有,

Log:

2023-12-11 20:26:06.382 12929-12929 FragmentMain            tech..                      I  SearchView displayMetrics = DisplayMetrics{density=1.3333334, width=2560, height=1600, scaledDensity=1.3333334, xdpi=239.058, ydpi=239.058, densityDpi=213, noncompatWidthPixels=2560, noncompatHeightPixels=1600, noncompatDensity=2.0, noncompatDensityDpi=320, noncompatXdpi=239.058, noncompatYdpi=239.058}
2023-12-11 20:26:06.382 12929-12929 FragmentMain            tech..                      I  SearchView displayMetrics = DensityImpl(density=2.0, fontScale=1.0)
2023-12-11 20:26:06.560 12929-12929 FragmentMain            tech..                      I  SearchView 627.dp = 836.0
2023-12-11 20:26:06.560 12929-12929 FragmentMain            tech..                      I  SearchView 627.dp = 836.0

Compose 在Layout 的时候 dp转 px的时候 使用的是
Density 2
fun Dp.toPx(): Float = value * density
方法。

但是 从日志中可以看到 Compose 的DensityImpl 的density 始终是2.0 没有被修改。

Related Code:

      @Stable
    fun Dp.toPx(): Float = value * density

    /**
     * Convert [Dp] to [Int] by rounding
     */
    @Stable
    fun Dp.roundToPx(): Int {
        val px = toPx()
        return if (px.isInfinite()) Constraints.Infinity else px.roundToInt()
    }

Others:

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

1 participant