xml里:
android:background="?android:attr/selectableItemBackground"
Java代码里:
int[] attrs =new int[]{R.attr.selectableItemBackground};
TypedArray typedArray =getContext().obtainStyledAttributes(attrs);
int backgroundResource =typedArray.getResourceId(0, 0);
view.setBackgroundResource(backgroundResource);
typedArray.recycle();
网友评论