Android TextSwitcher could not wrap content width after given text

I use TextSwitcher to put a fade in-fade out animation when I set the text. But there are some problems with the transfer of content along its width when changing text.

Below is my TextSwitched xml:

<TextSwitcher
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="5dp"
                            android:layout_marginRight="5dp"
                            android:background="#ffffff"
                            android:paddingBottom="1dp"
                            android:paddingLeft="7dp"
                            android:paddingRight="10dp"
                            android:paddingTop="1dp" >

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:ellipsize="end"
                                android:maxLines="1"
                                android:scrollHorizontally="true"
                                android:textAppearance="?android:attr/textAppearanceSmall"
                                android:textColor="@android:color/white" />

                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:ellipsize="end"
                                android:maxLines="1"
                                android:scrollHorizontally="true"
                                android:textAppearance="?android:attr/textAppearanceSmall"
                                android:textColor="@android:color/white" />
                        </TextSwitcher>

I have a list of lines and when I go from a long word, for example. "Hello World" in "World", the text manager does not overlap the width of the string "World", but preserves the width of the word "Hello World".

In a nutshell, the width remains fixed for the maximum width of the longest word.

Please offer !!!

+5
source share
1 answer

ViewAnimator .

, android:measureAllChildren="false" TextSwitcher

+12

All Articles