簡體   English   中英

如何使滾動視圖滾動到另一個布局上,布局保持完整但在滾動內容后面

[英]how to make a scroll view to scroll over another layout with the layout behind staying intact but behind scroll content

如何使滾動視圖滾動到另一個布局上,而后面的布局保持不變,但在滾動內容后面我的要求是應用程序的標題將保持固定,而如果其中的內容足夠大可以滾動,則它下面的布局將滾動,請提供給我或建議任何解決此問題的方法

嘗試這個:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    android:orientation="vertical">

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="100dp">

        <LinearLayout
            android:layout_width="269dp"
            android:layout_height="match_parent"
            android:orientation="vertical">

           <!-- any no. of views here -->
        </Linearlayout>
    <ScrollView>
</Linearlayout>

將此代碼添加到 onCreate():

scrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() {

                @Override
                public void onScrollChanged() {
                    Layout.setY(Layout.getY() + scrollView.getScrollY() - Layout.getY());


                }
            });

每次滾動視圖時,布局都會移動相反的值。 看起來它根本不動。 確保您的所有視圖都在 ScrollView 內。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM