自定义属性值传递不过去
打印出来的log ,position和radius都是 缺省值
打印出来的log ,position和radius都是 缺省值
2015-08-07
public ArcMenu(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ArcMenu, defStyleAttr, 0); int default_radius = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, 100, context.getResources() .getDisplayMetrics()); // mRadius = a.getDimensionPixelSize(R.styleable.ArcMenu_radius, // default_radius); mRadius = (int) a.getDimension(R.styleable.ArcMenu_radius, default_radius); int pos = a.getInt(R.styleable.ArcMenu_position, RIGHT_BOTTOM); switch (pos) { case LEFT_TOP: mPosition = position.LEFT_TOP; break; case LEFT_BOTTOM: mPosition = position.LEFT_BOTTOM; break; case RIGHT_TOP: mPosition = position.RIGHT_TOP; break; case RIGHT_BOTTOM: mPosition = position.RIGHT_BOTTOM; break; } a.recycle(); Log.i("hendry_arcmenu__", "position:" + mPosition + " radius:" + mRadius); }
可以正常读取的, 上面是我测试的代码, 你看看是不是a.getXxx 这个地方参数问题
举报