Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable blinking of textview onClick

Tags:

android

I have a TextView with an onClickListener(). When I click on the TextView it blinks. How to disable this effect?

Here is the XML

<TextView
                android:id="@+id/descriptionText"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@color/background"
                android:ellipsize="end"
                android:paddingTop="4dp"
                android:paddingLeft="8dp"
                android:maxLines="3"
                />

I tried to remove android:ellipsize and android:maxLines tags - no effect.

And here is the code:

accountDescriptionTextView = (TextView) v.findViewById(R.id.descriptionText);

        accountDescriptionTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (descriptionOpened)
            {
            //  accountDescriptionTextView.setEllipsize(TextUtils.TruncateAt.END);
            //  accountDescriptionTextView.setMaxLines(3);
                descriptionOpened = false;
            }
            else
            {
            //  accountDescriptionTextView.setEllipsize(null);
            //  accountDescriptionTextView.setMaxLines(100);
                descriptionOpened = true;
            }
        }
    });

I need to have the commented functionality, but even when this lines are commented I still see how the textview blinks.

The text just disapears when i place my finger on the screen and apears when I take the finger away.

like image 250
TpoM6oH Avatar asked Oct 04 '22 20:10

TpoM6oH


1 Answers

Android uses a selector to give different colors to widgets' pressed state.

If you don't want that behavior, you can use solid colors for android:textColor and android:textColorHighlight.

Check the TextView doc.

like image 119
Macarse Avatar answered Oct 10 '22 01:10

Macarse