效果圖:
重要屬性:
textView.setCompoundDrawablePadding(4);//設定圖檔和text之間的間距
textView.setPadding(-5, 0, 0, 0);//設定整體的padding
private TextView addDesc(String[] MemDescs, int i) {
String MemDesc = MemDescs[i];
TextView textView = new TextView(this);
textView.setText(MemDesc);
//在左側添加圖檔
Drawable drawable= getResources().getDrawable(R.drawable.gray_circle);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
textView.setCompoundDrawables(drawable, null, null, null);
textView.setTextColor(getResources().getColor(R.color.gray_textcolor_shen));
textView.setCompoundDrawablePadding(4);//設定圖檔和text之間的間距
textView.setPadding(-5, 0, 0, 0);
return textView;
}