/* * Copyright 2017 GcsSloop * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Last modified 2017-03-08 06:45:28 * * GitHub: https://github.com/GcsSloop * Website: http://www.gcssloop.com * Weibo: http://weibo.com/GcsSloop */ package com.gcssloop.diycode.utils; import android.content.Context; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import com.gcssloop.recyclerview.adapter.singletype.SingleTypeAdapter; /** * 当 RecyclerView 外围嵌套 ScrollView 时,将滚动事件交予上层处理 */ public class RecyclerViewUtil { public static <T extends SingleTypeAdapter> void init(Context context, RecyclerView recyclerView, T adapter) { LinearLayoutManager layoutManager = new LinearLayoutManager(context); layoutManager.setSmoothScrollbarEnabled(true); layoutManager.setAutoMeasureEnabled(true); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(layoutManager); recyclerView.setHasFixedSize(true); recyclerView.setNestedScrollingEnabled(false); } }