天天看點

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);      

繼續閱讀