AdevintaSpain / AdevintaSpain/Parallax-Layer-Layout

Impossible to reorder/insert new layers at runtime

オープン
#25 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
945
フォーク
81
PR マージ指標
30日以内にマージされた PR はありません

説明

It seems that the current API of this library makes it impossible to reorder the layers (or insert new layers) to ParallaxLayerLayout at runtime.

For example, consider this XML pseudocode:

```


```

I want to insert another view at index 0, 1, or 2, depending on how the layers are ordered.

```
val layerIndex = data.layerIndex
parallaxLayerLayout.addChild(myView, layerIndex)
```

The newly added layer will not have any parallax effect.

This is because `ParallaxLayerLayout.computeOffsets` is only called once after inflate - and it is a private method. Since the view has already been inflated, the offsets are never computed for the newly added layer, and it has no parallax effect.

**Workaround:**
Use reflection to call `ParallaxLayerLayout.computeOffsets()` after adding the new view.

**Proposed permanent fixes:**
- `ParallaxLayerLayout.LayoutParams.customIndex` should be public - if this field can be modified via XML, there should be no reason not to allow it to be modified programmatically.
- Override `addChild` methods to automatically update the layout params of all the other children to allow seamless, automatic insertion of new layers.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。