@Override
protected void buildModels(List<CarouselData> carousels) {
addButton
.textRes(R.string.button_add)
.clickListener((model, parentView, clickedView, position) -> {
callbacks.onAddCarouselClicked();
});
clearButton
.textRes(R.string.button_clear)
.clickListener(v -> callbacks.onClearCarouselsClicked())
.addIf(carousels.size() > 0, this);
header
.title("Header 1")
.caption("This is heading number 1");
header2
.title("Header 2")
.caption("This is heading number 2");
// "addTo" is not needed since implicit adding is enabled
// (https://github.com/airbnb/epoxy/wiki/Epoxy-Controller#implicit-adding)
shuffleButton
.textRes(R.string.button_shuffle)
.clickListener(v -> callbacks.onShuffleCarouselsClicked())
.addIf(carousels.size() > 1, this);
changeColorsButton
.textRes(R.string.button_change)
.clickListener(v -> callbacks.onChangeAllColorsClicked())
.addIf(carousels.size() > 0, this);
for (int i = 0; i < carousels.size(); i++) {
CarouselData carousel = carousels.get(i);
add(new CarouselModelGroup(carousel, callbacks));
}
}
This is the end result:
You can see that the Header 1 and Header 2 do not respect the grid spanCount. Can you please tell me why and how can I make it respect the grid spanCount?
I see that in our MainActivity, we have created a GridLayoutManager with spanCount = 2.
Now, this causes the "ADD", "CLEAR","SHUFFLE" and "CHANGE" buttons to each take up half the size of the screen.
However, the headerview does not respect the spanCount = 2 at all and fills up the fill width of the screen.
I created a duplicated headerview and called it headerview2:
I then added it to the SampleController.java:
This is the end result:
You can see that the Header 1 and Header 2 do not respect the grid spanCount. Can you please tell me why and how can I make it respect the grid spanCount?