내 RecyclerView는 MainActivity에 대한 CardViewRecyclerView 한 번
의 목록XML을 포함 카드를 넣을 수 있습니다.
XML 어댑터 내부 ViewHolder을 팽창하는 데 사용 :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/relativeLayout"
android:paddingTop="2dp"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">
<android.support.v7.widget.CardView
android:id="@+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardBackgroundColor="@android:color/holo_red_light"
card_view:cardPreventCornerOverlap="true"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="3dp"
card_view:contentPadding="7dp"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:id="@+id/relat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="false"
android:padding="10dp">
<TextView/>
//...
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
이 카드 클릭을하려면, 나는 these의 모든 솔루션을 시도 - two 인기 게시물,하지만 난 항상이 이상한 버그가 있습니다
을 한 번 RecyclerView를 클릭하지 않으면 처음으로 앱을 시작할 때 카드 목록이 스크롤되지 않습니다. 마치 RecyclerView가 처음에는 초점을 맞추지 않은 것처럼 보입니다.
또한, 나는 모든 클릭 리스너 또는 CardView의 클릭을하고, 단지 XML의 포커스 코드를 유지하기 위해 비슷한 방법으로 제거하는 경우 : 다음은 스크롤 바로 수행,
android:focusable="true"
android:focusableInTouchMode="false"
을하지만, 곧 어떤 클릭 (리스너) 메커니즘을 추가하거나 ViewHolder에 "android : clickable ="true ""를 포함 시키면 그 버그가 다시 나타납니다. 알려주십시오. 감사합니다.
이 변경만으로도 문제가 해결되지 않습니다. NestedScrollView를 제거하면 RecyclerView 영역이 더 이상 스크롤 할 수 없습니다. – DanSoren
@ DanSoren 사용중인 지원 라이브러리의 버전은 무엇입니까? –
또한'android : layout_height = "match_parent"'를 사용할 수 있습니까? –