JessYanCoding / JessYanCoding/AndroidAutoSize

Compose 没有效果

Aberta
#457 0 comentários 2 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Java
Estrelas
13.7k
Forks
2k
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

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

### Log:

```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:
```java
@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:

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Start with the Compose layout density path around DensityImpl and Dp.toPx(), using the reported DisplayMetrics and Android 9.0 Huawei WGR-W09 environment as the reproduction context. Compare Compose density with the existing native View scaling behavior, then verify that Compose dimensions use the expected adapted density rather than the logged value of 2.0.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
android, kotlin
Domínio
mobile
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.