CanPHP框架技术讨论

导航

 

1、XML方式

  1. <Button android:drawableLeft="@drawable/btn_strip_mark_on"></Button>
复制代码

2、JAVA代码

  1. Drawable img_on, img_off;
  2. Resources res = getResources();
  3. img_off = res.getDrawable(R.drawable.btn_strip_mark_off);
  4. // 调用setCompoundDrawables时,必须调用Drawable.setBounds()方法,否则图片不显示
  5. img_off.setBounds(0, 0, img_off.getMinimumWidth(), img_off.getMinimumHeight());
  6. btn.setCompoundDrawables(img_off, null, null, null); //设置左图标
复制代码
posted on 2013-01-18 13:45  創丗仼  阅读(1315)  评论(0编辑  收藏  举报