0

I have one ListView with some TextView. I am displaying file name in textview and I want marquee for large file name.

I have set ellipsize= "marquee" and set singleline="true". but unfortunately code not working.

Here is my xml layout file.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/ll_file"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="horizontal" >

    <FrameLayout
        android:layout_width="50dp"
        android:layout_marginLeft="10dp"
        android:layout_height="50dp" >

        <TextView
            android:id="@+id/tv_ext"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:ellipsize="marquee"
            android:gravity="center"
            android:marqueeRepeatLimit="marquee_forever"
            android:singleLine="true"
            android:textColor="@color/white"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/tv_mode"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:singleLine="true"
            android:textColor="@color/white"
            android:textIsSelectable="false"
            android:textSize="12sp"
            android:layout_gravity="end|bottom"
            android:padding="2dp"
            tools:ignore="SmallSp" />
    </FrameLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:orientation="horizontal"
        android:padding="10dp" >

        <LinearLayout
            android:id="@+id/layout"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1 "
            android:orientation="vertical" >

            <TextView
                android:id="@+id/tv_file_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:ellipsize="marquee"
                android:marqueeRepeatLimit="marquee_forever"
                android:scrollHorizontally="true"
                android:textColor="@color/black"
                android:textIsSelectable="false"
                android:textSize="15sp" />

            <TextView
                android:id="@+id/tv_info"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:singleLine="true"
                android:textColor="@color/black"
                android:textIsSelectable="false"
                android:textSize="10sp"
                tools:ignore="SmallSp" />

        </LinearLayout>

        <ImageView
            android:id="@+id/iv"
            android:layout_width="10dp"
            android:layout_height="10dp"
            android:layout_gravity="center"
            android:contentDescription="@null"
            android:src="@drawable/ic_notification"
            android:visibility="gone" />

        <CheckBox
            android:id="@+id/checkbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:paddingBottom="10dp"
            android:paddingLeft="10dp"
            android:paddingRight="0dp"
            android:paddingTop="10dp"
            android:visibility="visible" />
    </LinearLayout>

</LinearLayout>
Crazy Coder
  • 508
  • 1
  • 4
  • 12
  • 1
    [http://stackoverflow.com/questions/11311085/androids-textview-with-marquee-in-a-listview-wont-animate-for-the-fist-time-it](http://stackoverflow.com/questions/11311085/androids-textview-with-marquee-in-a-listview-wont-animate-for-the-fist-time-it) – M D Dec 23 '14 at 06:17

1 Answers1

1

please try this

YourTextView.setSelected(true);
YourTextView.requestFocus();

Also refer this answer :

Using setSelected on a textView inside a listItem inside a listView

Community
  • 1
  • 1
Shruti
  • 1
  • 13
  • 55
  • 95