This is the screenshot of what I am working on.
There are two classes involved here. DraggableLayout and DraggableChip. Now, I want to change the style of the chip to R.style.Widget_MaterialComponents_Chip_Entry
This is what the code looks like:
private void setupDraggableChipLayout() {
DraggableLayout draggableLayout = this.findViewById(R.id.draggableLayout);
androidx.appcompat.view.ContextThemeWrapper contextWrapper = new ContextThemeWrapper(this, R.style.Widget_MaterialComponents_Chip_Entry);
DraggableChip chip1 = new DraggableChip(contextWrapper, null, 0);
chip1.setText("Chip1");
chip1.enableCancelIcon(true);
DraggableChip chip2 = new DraggableChip(this);
chip2.setText("Chip2");
DraggableChip chip3 = new DraggableChip(this);
chip3.setText("Chip3");
draggableLayout.addChip(chip1);
draggableLayout.addChip(chip2);
draggableLayout.addChip(chip3);
}
I have tried using ContextWrapper but it does not work.
I have referred to this answer. But how to do it without using a layout file?