QuickContactBadge去掉三角

来源:互联网 发布:怎么下载word2010软件 编辑:程序博客网 时间:2024/06/02 01:49

我们首先来分析一下QuickContactBadge源码


在QuickContactBadge构造函数中会给mOverlay赋值

private Drawable mOverlay;public QuickContactBadge(            Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {        super(context, attrs, defStyleAttr, defStyleRes);        TypedArray styledAttributes = mContext.obtainStyledAttributes(R.styleable.Theme);        mOverlay = styledAttributes.getDrawable(                com.android.internal.R.styleable.Theme_quickContactBadgeOverlay);        styledAttributes.recycle();        if (!isInEditMode()) {            mQueryHandler = new QueryHandler(mContext.getContentResolver());        }        setOnClickListener(this);    }


所以我是利用java反射机制给mOverlay赋值为空

QuickContactBadge headImage = (QuickContactBadge)findViewById(R.id.head_image);//利用反射机制给QuickContactBadge.mOverlay复制为nulltry {Field f = headImage.getClass().getDeclaredField("mOverlay");f.setAccessible(true); f.set(headImage,null); } catch (Exception e) {e.printStackTrace();} 



效果图如下:



0 0
原创粉丝点击