Android:TextviewコードでDrawableを設定
1203 ワード
ソリューション
XMLでの類似
TextViewを使用してsetCompoundDrawables()を直接呼び出すとdrawableの追加が可能になりますが、追加が完了すると表示できなくなり、ソースコードを表示すると、こんな言葉がありました
The Drawables must already have had {@link Drawable#setBounds} called.
転載先:https://www.cnblogs.com/liyiran/p/6088437.html
public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom);
XMLでの類似
android:drawableLeft="@drawable/icon"
TextViewを使用してsetCompoundDrawables()を直接呼び出すとdrawableの追加が可能になりますが、追加が完了すると表示できなくなり、ソースコードを表示すると、こんな言葉がありました
The Drawables must already have had {@link Drawable#setBounds} called.
1 Drawable drawable = context.getResources().getDrawable(R.drawable
2 .todo_date_alert_2x);
3 drawable.setBounds(0,0,drawable.getMinimumWidth(),drawable.getMinimumHeight());
4 holder.todoDataALLDate.setCompoundDrawables(drawable, null, null, null);
転載先:https://www.cnblogs.com/liyiran/p/6088437.html