TextDrawable icon indicating copy to clipboard operation
TextDrawable copied to clipboard

two lines text with different size is possible?

Open LOG-TAG opened this issue 9 years ago • 7 comments

selection_084

I'm looking for easy solution for the above multi-line requirement !!

LOG-TAG avatar Mar 11 '15 10:03 LOG-TAG

Keyboard app. Text app. Cammands and code.:-) Hole lot of hours.

caraus avatar Apr 05 '15 05:04 caraus

Hey @LOG-TAG were u able to achieve that superscript (th) above 15 using this library...Please do let me know if its possible...Thnks

hardikamal avatar Jul 28 '15 06:07 hardikamal

@hardikamal That is Designed by graphics Designers :) But you can look at this http://stackoverflow.com/questions/3543454/subscript-and-superscript-a-string-in-android http://stackoverflow.com/questions/20597223/android-textview-superscript (look at the ans by @amulyakhare )

LOG-TAG avatar Jul 29 '15 04:07 LOG-TAG

@LOG-TAG i did this but it not working on textdrawable

hardikamal avatar Jul 30 '15 06:07 hardikamal

Hi guys, i trying to make it:

  @Override
   public void draw(Canvas canvas) {

    // this is already on the lib
    int width = this.width < 0 ? r.width() : this.width;
    int height = this.height < 0 ? r.height() : this.height;
    int fontSize = this.fontSize < 0 ? (Math.min(width, height) / 2) : this.fontSize;
    textPaint.setTextSize(fontSize);


       //this draw one line below another
        int yHeight = 10;
        canvas.drawText(text, width / 2, yHeight, textPaint);
        yHeight += textPaint.descent() - textPaint.ascent();
        canvas.drawText(text2, width / 2, yHeight, textPaint);

}

If you wish to draw with 2 diferents fontsizes, just create another textPaint and set another TextSize.

The problem there is that i dont know how to calculate the text size to draw it on the center of the circle. Can anyone help? Thanks in advance.

sagits avatar Aug 18 '15 19:08 sagits

Same issue, this ignores \n or line separators

SolomonBier avatar Sep 18 '15 21:09 SolomonBier

Yes, you have to use split in yours " " and use a for loop to draw each line. I got a new idea, you can create a canvas copy, draw everything and get its size to draw centered on the real one.

sagits avatar Sep 23 '15 18:09 sagits