Android 获取xml中的系统属性

TypedArray ta = context.obtainStyledAttributes(attrs, new int[] {

                android.R.attr.layout_width, android.R.attr.layout_height });

String w = ta.getString(0);

        String h = ta.getString(1);

        if (w.indexOf("-2") > -1) {

            throw new IllegalArgumentException(

                    "the UISwitch only can run exactly screen");

        }

        if (h.indexOf("-2") > -1) {

            throw new IllegalArgumentException(

                    "the UISwitch only can run exactly screen");

        }

ta.recirle()

你可能感兴趣的:(Android 获取xml中的系统属性)