Search code examples
javaandroidxmltextviewandroid-library

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" >

Solution

  • 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.