Android:Textview 通过代码设置 Drawable左上右下

Textview设置图片位置: 左上右下

 eg:
 
 
调用方法:
public void setCompoundDrawables(@Nullable Drawable left, @Nullable Drawable top,
        @Nullable Drawable right, @Nullable Drawable bottom) 


参数说明:四个参数分别位于TextView 左上右下四个方位
代码实际应用:
    //获取本地图片
Drawable top = mContext.getResources().getDrawable(R.mipmap.conversion_arrows_up);
top.setBounds(0, 0, top.getMinimumWidth(), top.getMinimumHeight());
//设置图片显示位置
 mTextview.setCompoundDrawables(null, null, top, null);


猜你喜欢

转载自blog.csdn.net/u014133119/article/details/80596878