xmlandroid-studioanimationtextviewfading

XML preview won't show with FadingAnimation


I have an issue with the 'com.tomer:fadingtextview:2.5'. The preview of my layout get completely invisible after I add this code in my XML:

    <com.tomer.fadingtextview.FadingTextView
    android:id="@+id/fading_text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:textSize="30sp"/>

The code compile just fine and works when I run it on my phone but not seing the layout is an issue when I work on it.

I've tried to refresh it but it won't work.

This is the error message :

 java.lang.NullPointerException   at com.tomer.fadingtextview.FadingTextView.startAnimation(FadingTextView.java:269)   at com.tomer.fadingtextview.FadingTextView.resume(FadingTextView.java:59)   
 at com.tomer.fadingtextview.FadingTextView.onAttachedToWindow(FadingTextView.java:101)   at android.view.View.dispatchAttachedToWindow(View.java:18347)   
 at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)   
 at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)  
 at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)   
 at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42) 
 Copy stack to clipboard   Tip: Try to refresh the layout.

Any idea what's causing it ?

Link to the github : https://github.com/rosenpin/fading-text-view


Solution

  • As they mention in the documentation :

    create folder called array and create an XML called example in it

    <string-array name="examples">
         <item>Hello</item>
         <item>Fading TextView</item>
    </string-array>
    

    then change your XML to :

    <com.tomer.fadingtextview.FadingTextView
        android:id="@+id/fading_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:textSize="30sp"
        app:texts="@array/examples"/>
    

    This worked fine for me

    Hope it help