Android:RecyclerView开始拖动增加行高

时间:2016-07-25 09:34:20

标签: android android-recyclerview

我是Android的初学者,现在我遇到了滚动回收者视图的问题。当我将数据绑定到回收器并首次运行时,它将显示为正常,但是当我开始拖动列表时,它会增加每行回收器的高度。我不知道真正的问题是什么。

Image When first loading

Image When start dragging

A. My source code in activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scrollbars="vertical" /></RelativeLayout>

B. My code in MainActivity.xml

    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    movieAdapter = new MovieAdapter(movieList);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(movieAdapter);
    this.loadMovieData();

C. Method loadMovieData()

 private void loadMovieData(){
    for(int i=1;i<=15;i++){
        Movie movie = new Movie("Movie"+i,"Genre"+i,"2015");
        movieList.add(movie);
    }
    movieAdapter.notifyDataSetChanged();
}

1 个答案:

答案 0 :(得分:0)

更改RecyclerView的高度

android:layout_height="wrap_content"

android:layout_height="match_parent"。 希望我能帮到你。