使用方式
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.GeniusLiu:QuickItemDecorationDemo:1.5.0'
}
可以在自定义的Application中:
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
QuickItemDecoration.setGlobalConfig(
ItemDecorationConfig.GlobalConfig.getInstance(
new ItemDecorationConfig()
.create()
.setRecyclerMarginTop(500)
.setRecyclerMarginBottom(500)
.setRecyclerMarginTopColor(Color.RED)
.setRecyclerMarginBottomColor(Color.YELLOW)
.setMarginBottomWhenNotMatch(false)
.setItemDivider(new ItemDivider()
.setColor(Color.BLUE)
.setMarginLeft(150)
.setMarginRight(0)
.setWidth(10))
.addIgnoreViewId(R.id.emptyView)
.build()));
QuickItemDecoration.setGlobalConfig(ItemDecorationConfig.GlobalConfig.getInstance(new ItemDecorationConfig().create().build()));
}
}
QuickItemDecoration quickItemDecoration = new QuickItemDecoration();
recyclerView.addItemDecoration(quickItemDecoration);
QuickItemDecoration quickItemDecoration = new QuickItemDecoration();
quickItemDecoration.getUpdateConfig().setRecyclerMarginTopColor(Color.BLUE).update();
recyclerView.addItemDecoration(quickItemDecoration);
这种方式只会改变update的参数,不会改变GlobalConfig中其他的参数
QuickItemDecoration quickItemDecoration = new QuickItemDecoration();
quickItemDecoration.setConfig(new ItemDecorationConfig().create().setRecyclerMarginTop(100).build());
recyclerView.addItemDecoration(quickItemDecoration);
QuickItemDecoration quickItemDecoration = new QuickItemDecoration();
quickItemDecoration.getUpdateConfig().addIgnoreViewId(R.id.emptyView).update();
recyclerView.addItemDecoration(quickItemDecoration);