diff --git a/flowlayout-lib/src/main/java/com/zhy/view/flowlayout/TagFlowLayout.java b/flowlayout-lib/src/main/java/com/zhy/view/flowlayout/TagFlowLayout.java index ba90897..a21b3d3 100644 --- a/flowlayout-lib/src/main/java/com/zhy/view/flowlayout/TagFlowLayout.java +++ b/flowlayout-lib/src/main/java/com/zhy/view/flowlayout/TagFlowLayout.java @@ -98,7 +98,7 @@ private void changeAdapter() { View tagView = adapter.getView(this, i, adapter.getItem(i)); tagViewContainer = new TagView(getContext()); - tagView.setDuplicateParentStateEnabled(true); + setDuplicateParentStateEnabled(tagView); if (tagView.getLayoutParams() != null) { tagViewContainer.setLayoutParams(tagView.getLayoutParams()); @@ -141,6 +141,14 @@ public void onClick(View v) { } mSelectedView.addAll(preCheckedList); } + private void setDuplicateParentStateEnabled(View view) { + view.setDuplicateParentStateEnabled(true); + if (view instanceof ViewGroup) { + for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { + setDuplicateParentStateEnabled(((ViewGroup) view).getChildAt(i)); + } + } + } public void setMaxSelectCount(int count) { if (mSelectedView.size() > count) { diff --git a/flowlayout/src/main/res/layout/fl.xml b/flowlayout/src/main/res/layout/fl.xml new file mode 100755 index 0000000..b1c3b64 --- /dev/null +++ b/flowlayout/src/main/res/layout/fl.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file