有什么办法可以在Android Talkback中宣布文本字段的可绘制

时间:2019-01-18 06:14:58

标签: android accessibility talkback

使用具有可绘制权限的自定义EditText

<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);
    }

我们如何设置可绘制权限的内容描述?

预先感谢

1 个答案:

答案 0 :(得分:0)

您可以在.setContentDescription(String)字段上使用.mDrawableRight方法。