Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide the text on a button in android?

Tags:

java

android

Please tell me how to hide the text on a button in android.

When I try this code, the button is hidden but I just want to hide the text on the button.

Button b= (Button)findViewById(R.id.follow);
b.setVisibility(View.GONE);

Please tell me how to solve this.

Thank you.

like image 488
The Ray of Hope Avatar asked Jul 31 '13 06:07

The Ray of Hope


2 Answers

I have a suggestion if you want to setText to a button but don't want to show it.

Just set the text in the xml

android:text="TEXT"

then make font to 0

android:textSize="0sp"

text exist but can't be seen.

like image 155
yhunz_19 Avatar answered Sep 24 '22 07:09

yhunz_19


On your button use mButton.setTextScaleX(0); so the text will be hidden and to show use mButton.setTextScaleX(1);

like image 26
hsul4n Avatar answered Sep 25 '22 07:09

hsul4n