android.widget.EditText.getCompoundDrawables()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中android.widget.EditText.getCompoundDrawables()方法的一些代码示例,展示了EditText.getCompoundDrawables()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EditText.getCompoundDrawables()方法的具体详情如下:
包路径:android.widget.EditText
类名称:EditText
方法名:getCompoundDrawables

EditText.getCompoundDrawables介绍

暂无

代码示例

代码示例来源:origin: rey5137/material

/**
 * Returns drawables for the left, top, right, and bottom borders.
 *
 * @attr ref android.R.styleable#TextView_drawableLeft
 * @attr ref android.R.styleable#TextView_drawableTop
 * @attr ref android.R.styleable#TextView_drawableRight
 * @attr ref android.R.styleable#TextView_drawableBottom
 */
public Drawable[] getCompoundDrawables (){
  return mInputView.getCompoundDrawables();
}

代码示例来源:origin: rey5137/material

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public Drawable[] getCompoundDrawablesRelative (){
  if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
    return mInputView.getCompoundDrawablesRelative();
  return mInputView.getCompoundDrawables();
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onTouch(View v, MotionEvent event) {
  if (et.getCompoundDrawables()[2] == null) {
    return false;

代码示例来源:origin: stackoverflow.com

@Override
public boolean onTouch(View v, MotionEvent event) {
  if (et.getCompoundDrawables()[2] == null) {
    return false;

代码示例来源:origin: ywwynm/EverythingDone

private boolean isPrivateThing() {
  Drawable start = mEtTitle.getCompoundDrawables()[0];
  return start != null;
}

代码示例来源:origin: com.albedinsky.android/ui

/**
 * <b>Note, that on pre {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android versions
 * this method will return array containing instances of {@link TintDrawable TintDrawable} (if any)
 * if compound drawable tint has been applied via {@link #setCompoundDrawableTintList(ColorStateList)}.</b>
 * <p>
 * The original wrapped drawables can be obtained via {@link TintDrawable#getDrawable()}.
 */
@NonNull
@Override
public Drawable[] getCompoundDrawables() {
  return super.getCompoundDrawables();
}

代码示例来源:origin: com.albedinsky.android/ui-widget-common

/**
 * <b>Note, that on pre {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android versions
 * this method will return array containing instances of {@link TintDrawable TintDrawable} (if any)
 * if compound drawable tint has been applied via {@link #setCompoundDrawableTintList(ColorStateList)}.</b>
 * <p>
 * The original wrapped drawables can be obtained via {@link TintDrawable#getDrawable()}.
 */
@NonNull
@Override
public Drawable[] getCompoundDrawables() {
  return super.getCompoundDrawables();
}

代码示例来源:origin: com.albedinsky.android/ui-widget-text

/**
 * <b>Note, that on pre {@link android.os.Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android versions
 * this method will return array containing instances of {@link TintDrawable TintDrawable} (if any)
 * if compound drawable tint has been applied via {@link #setCompoundDrawableTintList(ColorStateList)}.</b>
 * <p>
 * The original wrapped drawables can be obtained via {@link TintDrawable#getDrawable()}.
 */
@NonNull
@Override
public Drawable[] getCompoundDrawables() {
  return super.getCompoundDrawables();
}

代码示例来源:origin: kinecosystem/kin-ecosystem-android-sdk

public void setRevealIconColor(@ColorRes final int colorRes) {
  Drawable revealDrawable = passwordField.getCompoundDrawables()[DRAWABLE_RIGHT];
  if (revealDrawable != null) {
    final int color = ContextCompat.getColor(getContext(), colorRes);
    revealDrawable.setColorFilter(color, Mode.SRC_ATOP);
  }
}

代码示例来源:origin: sealtalk/sealtalk-android

@Override
  public boolean onTouch(View v, MotionEvent event) {
    final int DRAWABLE_RIGHT = 2;
    if (event.getAction() == MotionEvent.ACTION_UP) {
      if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
        filterInfo("");
        mSearchEditText.setText("");
        return true;
      }
    }
    return false;
  }
});

代码示例来源:origin: wythe0102/Mall

@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  Drawable right = charSequence.length() > 0 ? mClearDrawable : null;
  dialog.editText.setCompoundDrawables(dialog.editText.getCompoundDrawables()[0],
      dialog.editText.getCompoundDrawables()[1], right, dialog.editText.getCompoundDrawables()[3]);
  if (charSequence.length() > 0) {
    dialog.negButton.setBackgroundResource(R.drawable.button_a);
    dialog.negButton.setTextColor(context.getResources().getColor(R.color.button_a_font_color));
    dialog.negButton.setClickable(true);
  } else {
    dialog.negButton.setBackgroundResource(R.drawable.dialog_style7_button_bg);
    dialog.negButton.setTextColor(context.getResources().getColor(R.color.c_BFBFBF));
    dialog.negButton.setClickable(false);
  }
}

代码示例来源:origin: braintree/android-card-form

public static void assertNoHintIcon(EditText editText) {
  assertNull(editText.getCompoundDrawables()[0]);
  assertNull(editText.getCompoundDrawables()[1]);
  assertNull(editText.getCompoundDrawables()[2]);
  assertNull(editText.getCompoundDrawables()[3]);
}

代码示例来源:origin: kinecosystem/kin-ecosystem-android-sdk

private boolean isInRevealIconBounds(MotionEvent event) {
  final int drawableWidth = passwordField.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width();
  return (event.getRawX() >= (getRight() - drawableWidth - sidesPadding))
    && (event.getRawX() <= (getRight() - sidesPadding));
}

代码示例来源:origin: sealtalk/sealtalk-android

@Override
  public boolean onTouch(View v, MotionEvent event) {
    final int DRAWABLE_RIGHT = 2;
    if (event.getAction() == MotionEvent.ACTION_UP) {
      if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
        filterInfo("");
        mSearchEditText.setText("");
        mSearchEditText.clearFocus();
        return true;
      }
    }
    return false;
  }
});

代码示例来源:origin: sealtalk/sealtalk-android

@Override
  public boolean onTouch(View v, MotionEvent event) {
    final int DRAWABLE_RIGHT = 2;
    if (event.getAction() == MotionEvent.ACTION_UP) {
      if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
        mSearchEditText.setText("");
        mSearchEditText.clearFocus();
        return true;
      }
    }
    return false;
  }
});

代码示例来源:origin: sealtalk/sealtalk-android

@Override
  public boolean onTouch(View v, MotionEvent event) {
    final int DRAWABLE_RIGHT = 2;
    if (event.getAction() == MotionEvent.ACTION_UP) {
      if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
        mSearchEditText.setText("");
        mSearchEditText.clearFocus();
        return true;
      }
    }
    return false;
  }
});

代码示例来源:origin: sealtalk/sealtalk-android

@Override
  public boolean onTouch(View v, MotionEvent event) {
    final int DRAWABLE_RIGHT = 2;
    if (event.getAction() == MotionEvent.ACTION_UP) {
      if (event.getRawX() >= (mSearchEditText.getRight() - 2 * mSearchEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
        mSearchEditText.setText("");
        mSearchEditText.clearFocus();
        return true;
      }
    }
    return false;
  }
});

代码示例来源:origin: aliumujib/Nibo

@Override
  public boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_UP) {
      int leftEdgeOfRightDrawable = editText.getRight()
          - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width();
      // when EditBox has padding, adjust leftEdge like
      // leftEdgeOfRightDrawable -= getResources().getDimension(R.dimen.edittext_padding_left_right);
      if (event.getRawX() >= leftEdgeOfRightDrawable) {
        // clicked on clear icon
        editText.setText("");
        editText.clearFocus();
        return true;
      }
    }
    return false;
  }
};

代码示例来源:origin: wythe0102/Mall

@Override
  public boolean onTouch(View view, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_UP) {
      if (dialog.editText.getCompoundDrawables()[2] != null) {
        boolean touchable = event.getX() > (dialog.editText.getWidth() - dialog.editText.getTotalPaddingRight())
            && (event.getX() < ((dialog.editText.getWidth() - dialog.editText.getPaddingRight())));
        if (touchable) {
          dialog.editText.setText("");
        }
      }
    }
    return false;
  }
});

代码示例来源:origin: braintree/android-card-form

public static void assertIconHintIs(EditText editText, int resourceId) {
  Drawable expected;
  if (resourceId == 0) {
    expected = null;
  } else {
    expected = RuntimeEnvironment.application.getResources().getDrawable(resourceId);
  }
  Drawable[] drawables = editText.getCompoundDrawables();
  assertBitmapsEqual(null, drawables[0]);
  assertBitmapsEqual(null, drawables[1]);
  assertBitmapsEqual(expected, drawables[2]);
  assertBitmapsEqual(null, drawables[3]);
}

相关文章

微信公众号

最新文章

更多

EditText类方法