在实现设置TextView 上方显示图片的时候遇到 不显示的 现象。代码如下
mainTv.setCompoundDrawables(null, getResources().getDrawable(R.mipmap.home_press), null, null);
API 解释
Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables must already have had setBounds(Rect) called.
即对 Drawable 进行宽高设置即可
Drawable dra = getResources().getDrawable(R.mipmap.home_press);
dra.setBounds(0, 0, dra.getMinimumWidth(), dra.getMinimumHeight());
mainTv.setCompoundDrawables(null, dra, null, null);