Try creating a separate layout using android:duplicateParentState="true"
and inflate it in your class. It works for me on Android 4.0.4:
unreadable_relative_layout.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:duplicateParentState="true" > ... </RelativeLayout>
UnreadableRelativeLayout.java:
public class UnreadableRelativeLayout extends RelativeLayout { public UnreadableRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater factory = LayoutInflater.from(context); factory.inflate(R.layout.unreadable_relative_layout, this); } }
Guzik source share