i've tried to make Horizontal Scrolling like google play.Like this :
it scroll something like ViewPager
. Only focus one item from the left.
But when i implement the RecyclerView
and Horizontal LineararLayout manager , but scroll smoothly but not like google play. Code has been given bellow and can anyone help me to make the scrolling exactly like google play scrolling ?
Recyclerview Declaration :
RecyclerView nowShowingMovies;
.......
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
nowShowingMovies.setLayoutManager(layoutManager);
nowShowingMovies.setHasFixedSize(true);
NowShowingAdapter adapter = new NowShowingAdapter(getActivity());
nowShowingMovies.setAdapter(adapter);
Adapter Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:clickable="true"
android:paddingRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/movieImage"
android:layout_width="144dp"
android:layout_height="200dp"/>
</LinearLayout>
</LinearLayout>
AdapterClass :
public class NowShowingAdapter extends RecyclerView.Adapter<NowShowingAdapter.NowShowingViewHolder> {
MovieListClick movieListClick;
ArrayList<MovieListModel> movieListModel;
int movieImageId[] = new int[]{
R.drawable.kubo_image,
R.drawable.batman1,
R.drawable.jugnle_1,
R.drawable.kanfu_1,
R.drawable.peanuts,
R.drawable.sweetheart
};
Context context;
public NowShowingAdapter(Context context){
this.context = context;
}
@Override
public NowShowingViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.movie_for_list,null,false);
return new NowShowingViewHolder(view);
}
@Override
public void onBindViewHolder(NowShowingViewHolder holder, int position) {
holder.movieImage.setImageResource(movieImageId[position]);
}
public void setOnMovieClickListener(MovieListClick movieListClick){
this.movieListClick = movieListClick;
}
@Override
public int getItemCount() {
return movieImageId.length;
}
public class NowShowingViewHolder extends RecyclerView.ViewHolder {
public ImageView movieImage;
public NowShowingViewHolder(View itemView) {
super(itemView);
movieImage = (ImageView) itemView.findViewById(R.id.movieImage);
movieImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
movieListClick.onMovieClick(getLayoutPosition());
}
});
}
}
}