Highlight on clickablespan click

后端 未结 7 1460
夕颜
夕颜 2021-01-30 11:18

I\'ve got little problem, i need to remove or customize this orange highlight during clicking on clickablespan. This is my class extending ClickableSpan

public c         


        
相关标签:
7条回答
  • 2021-01-30 11:34

    just use this..

    view.setSelector(new ColorDrawable(Color.TRANSPARENT));
    
    0 讨论(0)
  • 2021-01-30 11:40
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout android:id="@+id/LinearLayout01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android">
    
        <LinearLayout android:id="@+id/LinearLayout02"
            android:layout_height="50px"
            android:layout_width="fill_parent"
            // Layout Click enable
            android:clickable="true"
            // Setting Highlight Option in background property
            android:background="@android:drawable/list_selector_background" />
        </LinearLayout>
    </LinearLayout>
    
    0 讨论(0)
  • 2021-01-30 11:43
    textView.setText(myString);
    Linkify.addLinks(textView,Linkify.ALL);
    

    This works for me.

    0 讨论(0)
  • 2021-01-30 11:45

    You can override onClick(View widget) like this:

            @Override
            public void onClick(View widget) {
                // do what must happen after click event.
                widget.invalidate();
            }
    
    0 讨论(0)
  • 2021-01-30 11:50

    ClickableSpan linkClick = new ClickableSpan() {
        @Override
        public void onClick(View view) {
            Toast.makeText(getApplicationContext(), "Link Click",
                    Toast.LENGTH_SHORT).show();
            view.invalidate();
        }
    
        @Override
        public void updateDrawState(TextPaint ds) {
            if (textView.isPressed()) {
                ds.setColor(Color.BLUE);
            } else {
                ds.setColor(Color.RED);
            }
            textView.invalidate();
        }
    };
    textView.setHighlightColor(Color.TRANSPARENT);
    
    Spannable spannableString = new SpannableString("Link in TextView");
    spannableString.setSpan(linkClick, 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    textView.setText(spannableString, TextView.BufferType.SPANNABLE);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    
    0 讨论(0)
  • 2021-01-30 11:53

    This will remove any highlight.

    tv.setHighlightColor(Color.TRANSPARENT);
    
    0 讨论(0)
提交回复
热议问题