Ejemplo n.º 1
0
 private void init(Context context) {
   this.mContext = context;
   this.mTextView = new TextView(mContext);
   // some config
   setClickable(true);
   setFocusable(true);
   setGravity(Gravity.CENTER);
   mTextView.setTextSize(22);
   RelativeLayout.LayoutParams params =
       new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   params.addRule(RelativeLayout.CENTER_HORIZONTAL);
   mTextView.setSelected(true);
   mTextView.setSingleLine(true);
   mTextView.setEllipsize(TruncateAt.MARQUEE);
   mTextView.setTransformationMethod(SingleLineTransformationMethod.getInstance());
   mTextView.setLayoutParams(params);
   mTextView.setTextColor(getResources().getColor(R.color.white));
   mTextView.getPaint().setFakeBoldText(true);
   addView(mTextView);
 }
  @SuppressWarnings("deprecation")
  protected void setPasswordButtonShown(boolean shouldShow) {
    // Changing input type loses position in edit text; let's try to maintain it.
    int start = passwordEdit.getSelectionStart();
    int stop = passwordEdit.getSelectionEnd();

    if (!shouldShow) {
      passwordEdit.setTransformationMethod(PasswordTransformationMethod.getInstance());
      showPasswordButton.setText(R.string.fxaccount_password_show);
      showPasswordButton.setBackgroundDrawable(
          getResources().getDrawable(R.drawable.fxaccount_password_button_show_background));
      showPasswordButton.setTextColor(
          getResources().getColor(R.color.fxaccount_password_show_textcolor));
    } else {
      passwordEdit.setTransformationMethod(SingleLineTransformationMethod.getInstance());
      showPasswordButton.setText(R.string.fxaccount_password_hide);
      showPasswordButton.setBackgroundDrawable(
          getResources().getDrawable(R.drawable.fxaccount_password_button_hide_background));
      showPasswordButton.setTextColor(
          getResources().getColor(R.color.fxaccount_password_hide_textcolor));
    }
    passwordEdit.setSelection(start, stop);
  }