4

Using a custom EditText that have drawable right

<com.sample.AmountEditText
                android:id="@+id/search_amount"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_marginTop="@dimen/dim_16dp"
                android:hint="@string/amount"
                android:maxLength="12"
                android:inputType="numberDecimal" />

AmountEditText.java

@Override
    @SuppressLint("ClickableViewAccessibility")
    public boolean onTouchEvent(MotionEvent event) {
        // TODO Auto-generated method stub
        setCursorVisibility(this.getRootView(), true);
        if(!this.isEnabled()){
            return false;
        }
        if (event.getAction() == MotionEvent.ACTION_UP && mDrawableRight != null) {
            mRectBounds = mDrawableRight.getBounds();
            final int x = (int) event.getX();
            final int y = (int) event.getY();
            if (x >= (this.getRight() - mRectBounds.width()) && x <= (this.getRight() - this.getPaddingRight()) && y >= this.getPaddingTop() && y <= (this.getHeight() - this.getPaddingBottom())) {
                {
                    this.setText("");
                }
                if (this != null) {
                    this.setSelection(this.getText().length());
                }
            }
        }
        return super.onTouchEvent(event);
    }

How can we set content description for drawable right?

Thanks in Advance

Azeela
  • 213
  • 3
  • 8

1 Answers1

-2

you can .setContentDescription(String) method on on .mDrawableRight field.

monatis
  • 534
  • 4
  • 8
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/21963855) – Johan Jan 18 '19 at 07:43
  • Why do you think that it does not provide an answer? The question is how to set content description for accessibility. – monatis Jan 18 '19 at 07:51
  • 2
    Actually you can't. There is no such method for a drawableRight – galaxigirl Jun 24 '19 at 14:45