簡體   English   中英

Scrollview不會滾動2列表視圖

[英]Scrollview doesn't scroll with 2 listview

我搜索了很多關於scrollview的主題,它不會滾動,但沒有人可以解決我的問題:/如果有人可以幫助我:)每個listview打印一些人當我從我的服務器執行請求通常當我向下滾動我的列表時第二個列表出現,但它沒有

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/selector_for_background_white"
    android:orientation="vertical">

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/selector_for_background_white"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:id="@+id/layoutScrollResult"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <RelativeLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:background="@drawable/selector_for_background_white">

                    <LinearLayout
                        android:id="@+id/layout2"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:orientation="horizontal">

                        <com.whask.whask.utils.font.FontTextView
                            android:id="@+id/text_hot"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerVertical="true"
                            android:layout_gravity="center"
                            android:layout_marginLeft="10dp"
                            android:layout_marginStart="10dp"
                            android:background="@android:color/transparent"
                            android:text="5 HOT"
                            android:textSize="@dimen/abc_text_size_medium_material"
                            app:font="Neo-Sans-Std-Medium.otf"/>
                    </LinearLayout>


                    <ListView
                        android:id="@+id/result_whask_listview_view"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/layout2">
                    </ListView>

                    <LinearLayout
                        android:id="@+id/layout3"
                        android:layout_width="match_parent"
                        android:layout_height="40dp"
                        android:layout_below="@+id/result_whask_listview_view"
                        android:orientation="horizontal">

                        <com.whask.whask.utils.font.FontTextView
                            android:id="@+id/text_not"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerVertical="true"
                            android:layout_gravity="center"
                            android:layout_marginLeft="10dp"
                            android:layout_marginStart="10dp"
                            android:background="@android:color/transparent"
                            android:text="2 NOT"
                            android:textSize="@dimen/abc_text_size_medium_material"
                            app:font="Neo-Sans-Std-Medium.otf"/>
                    </LinearLayout>

                    <ListView
                        android:id="@+id/result_whask_listview_view_no"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/layout3"
                        android:background="@color/my_whask_white_color">
                    </ListView>

                </RelativeLayout>

            </LinearLayout>

        </LinearLayout>

    </ScrollView>

</LinearLayout>

不要ScrollView使用ListView ListView本身有一個scroll屬性,你不必使用另一個ScrollView來滾動它。 請改用LinearLayout

Listview有自己的滾動屬性,所以不要在scrollview中使用...謝謝

如果你想在Scrollview中滾動listview而不是這樣做。

 ListView result_whask_listview_view;
 result_whask_listview_view = (ListView)findViewById(R.id.result_whask_listview_view);

 result_whask_listview_view.setOnTouchListener(new ListView.OnTouchListener() {
                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        int action = event.getAction();
                        switch (action) {
                            case MotionEvent.ACTION_DOWN:
                                // Disallow ScrollView to intercept touch events.
                                v.getParent().requestDisallowInterceptTouchEvent(true);
                                break;

                            case MotionEvent.ACTION_UP:
                                // Allow ScrollView to intercept touch events.
                                v.getParent().requestDisallowInterceptTouchEvent(false);
                                break;
                        }

                        // Handle ListView touch events.
                        v.onTouchEvent(event);
                        return true;
                    }
                });

這樣你就可以在scrollview中滾動listview。

希望它能幫到你:)

暫無
暫無

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

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