AndroidでTextView、ButtonなどのセットアップsetCompoundDrawablesが無効です

636 ワード

TextView上に画像が表示されるように設定すると表示されない現象が発生します.
コードは次のとおりです:tv_crbt_failed.setCompoundDrawables(getResources().getDrawable(R.drawable.icon_remind_new), null, 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.drawable.icon_remind_new); dra.setBounds(0, 0, dra.getMinimumWidth(), dra.getMinimumHeight()); tv_crbt_failed.setCompoundDrawables(dra, null, null, null);