动态为TextView控件设置drawableLeft图标,并设置间距
效果图:
重要属性:
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;
	}
 
                    
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号