Droidzilla
Droidzilla

Reputation: 137

Unable to Set Text Size Using FlowTextView

I found a library which allows an app to wrap text around an image - however once implemented it changed the size of my text - how can the text size be increase when using this library?

android:textSize= has no impact on the text size.

Neither does:

FlowTextView titleTv = (FlowTextView) findViewById(R.id.titleTv);
((FlowTextView) findViewById(R.id.titleTv)).setTextSize(20);

https://code.google.com/p/android-flowtextview/

Example:

<com.pagesuite.flowtext.FlowTextView
    android:id="@+id/titleTv"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="5dp"
    android:text=""
    android:textSize="20sp" >

Upvotes: 1

Views: 1020

Answers (3)

Dean Wild
Dean Wild

Reputation: 5964

In the short term a call to invalidate will probably get it working:

FlowTextView titleTv = (FlowTextView) findViewById(R.id.titleTv);
titleTv.setTextSize(20);
titleTv.invalidate();

However, I suspect you are using the JAR file right? It is quite out of date so I would recommend checking the source code out and using it as an android library project - setTextSize() should work properly then without needing a call to invalidate() (plus various other bug fixes etc).

Also - I never added the ability to set the text size via XML - wouldn't be too hard to add this though.

Upvotes: 1

danh32
danh32

Reputation: 6244

https://code.google.com/p/android-flowtextview/source/browse/trunk/src/com/pagesuite/flowtext/FlowTextView.java

There's a 'setTextSize(int)' method that should do exactly what you're looking for.

If you want to set it from XML, it's a little more involved. Since FlowTextView's constructors ignore the AttributeSet that gets passed in, you'll have to code this yourself. Follow guides like this: http://kotikan.com/blog/posts/2012/09/android-attributes to figure out how to add custom attributes to your views.

Upvotes: 0

gnclmorais
gnclmorais

Reputation: 4961

I checked the code of android-flowtextview and they have the text size hardcoded (check line 131 here). You have to change their source code or use the public method setTextSize(int).

Also, this link might help you, as seems that someone already did something as you are trying to do.

Upvotes: 0

Related Questions