ShowcaseView icon indicating copy to clipboard operation
ShowcaseView copied to clipboard

Setting TextPaint has no effect

Open danielbanks opened this issue 9 years ago • 13 comments

I create a text paint variable as per the sample

Typeface typeface = Typeface.createFromAsset(activity.getAssets(), "fonts/Vollkorn-Regular.otf");
paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
paint.setTypeface(typeface);
paint.setTextAlign(Paint.Align.LEFT);

I then set this to my current showcase view

currentView =  new ShowcaseView.Builder(activity).setTarget(new ViewTarget(properties.getTargetView()))
   .blockAllTouches()
   .setStyle(R.style.Tutorial)
   .setContentTitlePaint(paint)
   .setContentTitle(properties.getMsg())
   .replaceEndButton(newButton)
   .build();

However I see no change from android's default font.

danielbanks avatar Jan 29 '16 15:01 danielbanks

Whoops! I'll take a look

amlcurran avatar Feb 09 '16 21:02 amlcurran

Hi @danielbanks, I can't seemingly reproduce this. What version of the library are you using, and on what devices/Android versions?

amlcurran avatar Feb 09 '16 21:02 amlcurran

Even I'm not able to set text paint , library is 5.4.0

Saudasadaf avatar Feb 10 '16 07:02 Saudasadaf

@amlcurran Library is 5.4.0 and we tested mainly on A samsung s5 (G900P) running android 5.0

danielbanks avatar Feb 10 '16 11:02 danielbanks

Using the latest sample app on an S4 running 5.0.1 works fine for me. Could you see if the "Custom Text" sample looks the same for you on your device? The sample app is available from Google Play or as an APK

device-2016-02-10-124743

amlcurran avatar Feb 10 '16 12:02 amlcurran

Found the issue!

amlcurran avatar Feb 10 '16 21:02 amlcurran

This should be fixed as of version 5.4.1 which I just released, can you please check that fixes your problem?

amlcurran avatar Feb 10 '16 22:02 amlcurran

This has not completely fixed my issue. I can setStrikeThruTest to true and see the strike through, I can also change the text alignment, but changing the typeface or the colour have no effect. However I can change the text colour using a custom style, so the main issue is being able to change the typeface.

danielbanks avatar Feb 11 '16 11:02 danielbanks

@danielbanks and what about the demo app, does that work correctly on your device? That uses a custom typeface.

amlcurran avatar Feb 11 '16 15:02 amlcurran

@amlcurran Yep the demo app works fine. I also downloaded the demo app font and tried to apply that, but there was no change.

danielbanks avatar Feb 11 '16 17:02 danielbanks

Sorry I haven't replied! So the typeface isn't working? Are you using Calligraphy or any other library which changes the font?

amlcurran avatar Apr 06 '16 20:04 amlcurran

@amlcurran, facing the same issue. TextPaint has no effect on the text of the showcase. Tried doing this:

TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(Color.YELLOW);
textPaint.setTextSize(activity.getResources().getDimension(R.dimen.showcase_size));
textPaint.setTypeface(Typeface.createFromAsset(activity.getAssets(), "RobotoSlab-Regular.ttf"));

which didn't really change the text at all, though in the sample app it seems to be working fine. Additional info:

  • Using Calligraphy for changing the font.
  • Using the 5.4.3 version of the library.
  • Using it on 4.4+ devices

VisheshVadhera avatar Aug 03 '16 06:08 VisheshVadhera

Experience this as well, but managed to make it work.

I was initially setting all the styles via styles.xml and setting it in the builder. The font doesn't seem to work when you set it from the xml. Tried the TextPaint fix, but didn't work initially -- the reason was because I was still setting the style when building the ShowcaseView. Removed the corresponding sv_titleTextAppearance and sv_detailTextAppearance in the styles, then moved the .setStyle in builder first before setting the paints like so:

final ShowcaseView sv = new ShowcaseView.Builder(this)
                    .setTarget(new ViewTarget(tab))
                    .setStyle(R.style.CustomShowcaseTheme)
                    .setContentTitle(getString(R.string.title))
                    .setContentTitlePaint(titlePaint)
                    .setContentText(getString(R.string.description))
                    .setContentTextPaint(descriptionPaint)
                    .singleShot(1L)
                    .build();

Font specified worked as expected. My guess is that calling .setStyle() after .setContentTitlePaint() and .setContentTextPaint() overrides the values and sets it to default.

yelsane avatar Feb 22 '18 07:02 yelsane