如何删除drawableleft [英] How to remove drawableleft

查看:94
本文介绍了如何删除drawableleft的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮和一个text-view,text-view有一个drawable-left. 单击按钮后,应该将drawable-left删除,并将纯文本设置为Text-view,但是我不知道如何从代码中删除drawable-left.

I have a button and a text-view, text-view has a drawable-left. After click on button the drawable-left should be removed and a plain text should be set to Text-view, but I don’t know how to remove drawable-left from code.

谢谢.

推荐答案

可以修改drawableLeft(或任何类似的属性)XML属性(在您的情况下删除drawable ),使用类似以下代码的代码:

The drawableLeft (or any of the similar attributes) XML attribute can be modified (removing a drawable in your case) via code using something like this:

yourTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
yourTextView.setText("The Text You Need In There");

该方法的构造函数按以下顺序进行:

The constructor for the method is in this order:

setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom)

详细了解方法 setCompoundDrawablesWithIntrinsicBounds这里

这篇关于如何删除drawableleft的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆