文本可以在 上下,左右 四个方位添加图片,icn.setBounds(0, 0, icn.getMinimumWidth(), icn.getMinimumHeight());这句没有加是不会成功显示图片的,这里记录一下,增强记忆,免得下次忘记
Drawable icn = null;
icn = ContextCompat.getDrawable(this,R.mipmap.icon_logo);
icn.setBounds(0, 0, icn.getMinimumWidth(), icn.getMinimumHeight());//这句千万要加,不加不会显
TextView titleTxt = (TextView)mToolbar.findViewById(R.id.titleTxt);
titleTxt.setCompoundDrawables(icn,null,null,null);
titleTxt.setPadding(0,Utils.dip2px(this,10),0,0);