zoukankan      html  css  js  c++  java
  • 动态为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;
    	}
    


  • 相关阅读:
    多表查询 left join
    对JS关于对象创建的几种方式的整理
    常见正则表达式
    spring
    富文本编辑器
    Struts2快速入门
    一个MySql Sql 优化技巧分享
    maven
    day3
    Spring MVC
  • 原文地址:https://www.cnblogs.com/mfmdaoyou/p/6894749.html
Copyright © 2011-2022 走看看