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

LithoView couldn't be shown when scrolled up inside a ScrollView #760

Closed
1 task done
ihenk opened this issue Jan 23, 2021 · 2 comments
Closed
1 task done

LithoView couldn't be shown when scrolled up inside a ScrollView #760

ihenk opened this issue Jan 23, 2021 · 2 comments

Comments

@ihenk
Copy link

ihenk commented Jan 23, 2021

Version

0.39.0

Issues and Steps to Reproduce

Hi, there. There is a SrollView that includes a LinearLayout as its root view. The LinearLayout contains a top view and a LithoView. The height of the top view is beyond screen height. The LithoView couldn't be shown when I scrolled up the screen, but I can see it occupies the height I set. Is there something wrong? I'm looking forward to hearing from you. Thank you.
image

Expected Behavior

The LithoView should be shown when scrolled up the screen. If I set the height of the top view less than screen height, LithoView shows immediately.
image

Link to Code

activity_main.xml
`

<LinearLayout
    android:id="@+id/containView"
    android:layout_width="match_parent"
    android:layout_height="1000dp"
    android:orientation="vertical"
    >

    <View
        android:id="@+id/topView"
        android:layout_width="match_parent"
        android:layout_height="1000dp"
        android:background="@android:color/holo_blue_light"
        />

</LinearLayout>

`

MainActivity.java
`public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SoLoader.init(this, false);

    setContentView(R.layout.activity_main);

    LinearLayout container = findViewById(R.id.containView);

    ComponentContext context = new ComponentContext(this);
    container.addView(LithoView.create(this,
            Text.create(context).widthPercent(100).backgroundColor(Color.GREEN).alignment(TextAlignment.CENTER).text("This is a Litho Text").heightDip(50)
                    .build()));
}

}`

Demo

QDynamicLib.zip

@akotra1999
Copy link
Contributor

You have to perform a manual incremental mount for the LithoView. This part of the docs explains it.

When the visible bounds of the ScrollView change, you have to let Litho know. This snippet of code should solve your issue. Let me know if you have any more questions.

scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
            
           @Override
            public void onScrollChanged() {
                lithoView.notifyVisibleBoundsChanged();
            }
 });

@ihenk
Copy link
Author

ihenk commented Mar 2, 2021

My bad. I didn't notice that. I set 'incrementalMount(false)' as a solution before. Thanks @akotra1999

@ihenk ihenk closed this as completed Mar 20, 2021
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