Warning: SQLite3Stmt::execute(): Unable to execute statement: database is locked in /www/wwwroot/blog.litecoder.top/var/Typecho/Db/Adapter/SQLite.php on line 82
标签 drawable 下的文章 - 码上啥都有

用代码为TextView设置drawable

用代码为TextView,Button 等设置drawableLeft,drawableRight,drawableTop,drawableBottom

以drawableLeft为例:

解决方案:

[codesyntax lang="java" container="none" tab_width="4"]

public void setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom);

类似调用方法如下:

1.在XML中使用 android:drawableLeft="@drawable/icon"

2.代码中动态变化 Drawable drawable= getResources().getDrawable(R.drawable.drawable);

/// 这一步必须要做,否则不会显示.

drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); myTextview.setCompoundDrawables(drawable,null,null,null);

也或参考另一个函数

public void setCompoundDrawablesWithIntrinsicBounds (Drawable left,Drawable top, Drawable right, Drawable bottom) [/codesyntax]

参考网址:http://bbs.csdn.net/topics/390383463