Android: Long-Click text on button


In my android-app I’m trying to create a button with two lines of text. One will display what the button is doing when (short) clicked, the other one should show the effect when long-clicked and that the button can be long-clicked. Just like on the the standerd keyboard of the android system (see picture).

What i’ve tried:

Bitmap canvasBitmap = Bitmap.createBitmap(64, 24, Bitmap.Config.ARGB_8888);
Canvas imageCanvas = new Canvas(canvasBitmap);
Paint imagePaint = new Paint();
imageCanvas.drawText(String, pxwidth/2, pxheight, imagePaint);
image = new BitmapDrawable(canvasBitmap);
((TextView) findViewById(,image,null,null);

But it isn’t suported at my currend API version (API 9 / GINGERBREAD / Android 2.3)
Can you please help me out?


If you need to target 9, then you can’t use that function, and you’ll need to use another technique. One way I can think of is to use an ImageButton instead of a button, prerender the image of the entire button, and apply it to the new ImageButton in xml.

Answered By – Gabe Sechan

Answer Checked By – Mildred Charles (AngularFixing Admin)

Leave a Reply

Your email address will not be published.