<TextView
android:id="@+id/tv_weixin"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:drawableLeft="@drawable/wechat_normal1"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:text="微信买单"
android:textColor="@color/white"
app:corners_radius="5dp"
app:solid_color="@color/gree" />
android:drawablePadding="15dp" 是设置图片和“微信买单”这几个字的距离的,
下面的方法是设置图片大小的。
TextView weixin = (TextView) findViewById(R.id.tv_weixin);
paddingPicture(weixin, R.drawable.wechat_normal1);
private void paddingPicture(TextView tv, int pic) {
Drawable drawable1 = getResources().getDrawable(pic);
drawable1.setBounds(20, 0, 120, 80);//第一0是距左边距离,第二0是距上边距离,40分别是长宽
tv.setCompoundDrawables(drawable1, null, null, null);//只放左边
}