2017-03-22 1 views
1

선형 레이아웃 관리자를 사용하여 아이템을 표시하는 리사이클 러 뷰를 만들었습니다.RecyclerView 관련 문제

이것은 내 RecyclerView입니다.

<com.example.Recycler.RecyclerView 
    android:id="@+id/recycler1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/> 

그리고 이것은 내가 RecyclerView에 사용하고있는 항목 레이아웃입니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:padding="5dp" 
    android:layout_height="wrap_content"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="16dp" 
     android:id="@+id/content"/> 

</LinearLayout> 

모든 것이 잘 작동하지만 작은 문제가 있습니다. 내가 리사이클을 채우는 데이터는 10 개의 항목입니다.

일부 장치의 리사이클 러는 10 개의 항목을 표시하고, 다른 장치에서는 3 개의 항목 만 표시하고 나머지는 표시하는 스크롤바를 만듭니다.

나는 리사이클 러에서 android:scrollbars="none"을 사용하려고 시도했지만 리사이클 러는 단지 3 개의 아이템 만 보여 주었다.

setNestedScrollingEnabled(false);을 사용해 보았지만 작동하지 않았습니다.

어떤 도움이 필요합니까?

+0

'android.support.v7.widget.RecyclerView'를 사용할 때 어떤 문제가 있습니까? –

답변

1

RecyclerView ~ match_parent의 높이를 지정해야합니다. 여기

코드가 있어야합니다입니다 :

<com.example.Recycler.RecyclerView 
    android:id="@+id/recycler1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 
1

사용 RecyclerView android.support.v7.widget.RecyclerView 대신 사용자 정의가

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recycler1" 
    android:scrollbars="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

</android.support.v7.widget.RecyclerView> 

RecyclerView 위젯 com.example.Recycler.RecyclerView는 V7 지원 라이브러리의 일부입니다. 프로젝트에서이 위젯을 사용하려면 사용자 정의 RecyclerView를 사용했기 때문에 응용 프로그램 모듈에 Gradle 종속성을 아래에 추가하십시오.

dependencies { 
    ... 
    compile 'com.android.support:recyclerview-v7:25.0.+' 
}