textview动态设置 DrableLeft 以及改变图片大小

来源:互联网 发布:51游戏java官网 编辑:程序博客网 时间:2024/06/05 10:10
        if (i_count==0){            Drawable drawable1= getResources().getDrawable(R.drawable.ic_news_comment_write);/// 这一步必须要做,否则不会显示.            drawable1.setBounds(0, 0, 30, 30);            tvComment.setCompoundDrawables(drawable1,null,null,null);//            tvComment.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_news_comment_write,0,0,0);            tvComment.setText("写评论");        }else {            Drawable drawable2= getResources().getDrawable(R.drawable.ic_comment_top);/// 这一步必须要做,否则不会显示.            drawable2.setBounds(0, 0, drawable2.getMinimumWidth(), drawable2.getMinimumHeight());            tvComment.setCompoundDrawables(drawable2,null,null,null);            tvComment.setText(" "+count + " 评论");        }        tvComment.setVisibility(isLoaded ? View.VISIBLE : View.GONE);

}

根据评论数:

drawable1.setBounds(0, 0, 30, 30);   控制图片大小   第一0是距左边距离,第二0是距上边距离,30分别是长宽

0 0
原创粉丝点击