/** * Forces a view to duplicate its parent state, working around a bug whereby the attribute only * works if set before the view is added to its parent. */ private void setDuplicateParentState(View view) { view.setDuplicateParentStateEnabled(true); ViewGroup parent = (ViewGroup) view.getParent(); if (parent == null) { return; } int index = parent.indexOfChild(view); parent.removeViewAt(index); parent.addView(view, index); }
private void mountView(View view, int flags) { view.setDuplicateParentStateEnabled(MountItem.isDuplicateParentState(flags)); mIsChildDrawingOrderDirty = true; // A host has been recycled and is already attached. if (view instanceof ComponentHost && view.getParent() == this) { finishTemporaryDetach(view); view.setVisibility(VISIBLE); return; } LayoutParams lp = view.getLayoutParams(); if (lp == null) { lp = generateDefaultLayoutParams(); view.setLayoutParams(lp); } if (mInLayout) { super.addViewInLayout(view, -1, view.getLayoutParams(), true); } else { super.addView(view, -1, view.getLayoutParams()); } }
@Test public void testDuplicateParentStateOnViews() { View v1 = mock(View.class); mount(0, v1); View v2 = mock(View.class); mount(1, v2, LAYOUT_FLAG_DUPLICATE_PARENT_STATE); verify(v1, times(1)).setDuplicateParentStateEnabled(eq(false)); verify(v2, times(1)).setDuplicateParentStateEnabled(eq(true)); }
public void configureCustom(View content) { markConfigured(true); // The focused state should be rendered by the content. setBackgroundDrawable(null); // Prevent the content from receiving events, but let it reflect the correct state. content.setFocusable(false); content.setFocusableInTouchMode(false); content.setClickable(false); content.setDuplicateParentStateEnabled(true); removeAllViews(); addView(content); }
tagView.setDuplicateParentStateEnabled(true); if (tagView.getLayoutParams() != null) { tagViewContainer.setLayoutParams(tagView.getLayoutParams());
public void run(RapidParserObject object, Object view, Var value) { ((View)view).setDuplicateParentStateEnabled(value.getBoolean()); } }
tagView.setDuplicateParentStateEnabled(true); if (tagView.getLayoutParams() != null) { tagViewContainer.setLayoutParams(tagView.getLayoutParams());
tagView.setDuplicateParentStateEnabled(true); if (tagView.getLayoutParams() != null)