请问一下如何查看xml中的属性在java代码中被引用的位置?
<!--cradview -->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="80dp"
android:clipChildren="false"
app:cardBackgroundColor="@color/actionsheet_gray">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="-20dp"
android:background="@mipmap/ic_launcher"/>
</android.support.v7.widget.CardView>
<!--linearlayout,framelayout, relativelayout等 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@color/actionsheet_gray"
android:orientation="vertical"
>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="-20dp"
android:background="@mipmap/ic_launcher"/>
</LinearLayout>
哦我现在在ViewGroup
找到了使用的地方initFromAttributes
private void initFromAttributes(
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewGroup, defStyleAttr,
defStyleRes);
final int N = a.getIndexCount();
for (int i = 0; i < N; i++) {
int attr = a.getIndex(i);
switch (attr) {
case R.styleable.ViewGroup_clipChildren:
setClipChildren(a.getBoolean(attr, true));
break;
case R.styleable.ViewGroup_clipToPadding:
setClipToPadding(a.getBoolean(attr, true));
break;
//...
对这个属性有影响的内容
public void setClipChildren(boolean clipChildren) {
boolean previousValue = (mGroupFlags & FLAG_CLIP_CHILDREN) == FLAG_CLIP_CHILDREN;
if (clipChildren != previousValue) {
setBooleanFlag(FLAG_CLIP_CHILDREN, clipChildren);
for (int i = 0; i < mChildrenCount; ++i) {
View child = getChildAt(i);
if (child.mRenderNode != null) {
child.mRenderNode.setClipToBounds(clipChildren);
}
}
invalidate(true);
}
}