From 05164f3433e635502957037b909008a9df6fe558 Mon Sep 17 00:00:00 2001 From: xiayong Date: Tue, 21 Aug 2018 11:54:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=89=E6=8B=A9=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=B8=8D=E8=83=BD=E5=90=8C=E6=AD=A5=E7=BB=99=E5=AD=90?= =?UTF-8?q?view=20=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zhy/view/flowlayout/TagFlowLayout.java | 10 +++++++++- flowlayout/src/main/res/layout/fl.xml | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755 flowlayout/src/main/res/layout/fl.xml 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