2016-05-16 79 views
0

我有一個RecyclerView,其中包含帶有ScrollView的CardView。但CardView不響應點擊。當我刪除ScrollView它完美的工作。有沒有什麼方法可以使ScrollView響應點擊?可滾動CardView無法響應點擊

我的CardView看起來像這樣;

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:card_view="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/card_view" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     card_view:cardCornerRadius="4dp" 
     card_view:cardUseCompatPadding="true"> 

    <ScrollView 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 
android:fillViewport="true"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 


    </LinearLayout> 
     </ScrollView> 
</android.support.v7.widget.CardView> 
+2

在另一個可滾動視圖(recyclerview)中有scrollview會導致這樣的問題。 –

+0

@Santosh請點擊代碼或參考coderzpassion.com教程。您應該使用NestedScrollView而不是ScrollView –

回答

0

你不能把一個滾動視圖的另一個滾動視圖中,在這種情況下,你recyclerview默認情況下它是滾動的,所以當你把回收站內的另一個滾動視圖查看滾動衝突會出現,在聰明的話它不支持那種行爲。

注意 可以使用recyclerview內滾動視圖,只有當你知道回收的高度或u需要計算的高度。

+0

感謝您的回覆。我嘗試使用NestedScrollView,並將recyclerview的高度更改爲固定值。但它仍然不可點擊。 – Santosh

+0

我檢查滾動視圖內的回收站視圖將工作在固定高度,但不可能將scrollview放置在回收站視圖內,只要我不行,因爲我現在已經嘗試過了。我已經編輯了答案。 –