效果圖:
重要屬性:
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; }