android.widget.TextView#getCurrentTextColor ( )源码实例Demo

下面列出了android.widget.TextView#getCurrentTextColor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: VCL-Android   文件: PlaybackSpeedDialog.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog_playback_speed, container);
    mSpeedValue = (TextView) view.findViewById(R.id.playback_speed_value);
    mSeekSpeed = (SeekBar) view.findViewById(R.id.playback_speed_seek);
    mPlaybackSpeedIcon = (ImageView) view.findViewById(R.id.playback_speed_icon);

    mSeekSpeed.setOnSeekBarChangeListener(mSeekBarListener);
    mPlaybackSpeedIcon.setOnClickListener(mResetListener);
    mSpeedValue.setOnClickListener(mResetListener);

    mTextColor = mSpeedValue.getCurrentTextColor();


    getDialog().setCancelable(true);
    getDialog().setCanceledOnTouchOutside(true);
    Window window = getDialog().getWindow();
    window.setBackgroundDrawableResource(Util.getResourceFromAttribute(getActivity(), R.attr.rounded_bg));
    window.setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    return view;
}
 
private boolean recurseGroup(@NonNull ViewGroup gp) {
    int count = gp.getChildCount();
    for (int i = 0; i < count; ++i) {
        View v = gp.getChildAt(i);
        if (v instanceof TextView) {
            TextView text = (TextView) v;
            String szText = text.getText().toString();
            if ("COLOR_SEARCH_1ST".equals(szText)) {
                mDefaultTextColor = text.getCurrentTextColor();
            }
        } else if (gp.getChildAt(i) instanceof ViewGroup) {
            if (recurseGroup((ViewGroup) v)) {
                return true;
            }
        }
    }
    return false;
}
 
源代码3 项目: PaymentKit-Droid   文件: AnimUtils.java
/**
 * @param shouldResetTextColor if true make sure you end the previous animation before starting this one.
 */
public static ObjectAnimator getShakeAnimation(final TextView textView, final boolean shouldResetTextColor) {
    final int textColor = textView.getCurrentTextColor();
    textView.setTextColor(Color.RED);

    ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(textView, "translationX", -16);
    shakeAnim.setDuration(SHAKE_DURATION);
    shakeAnim.setInterpolator(new CycleInterpolator(2.0f));
    shakeAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator anim) {
            if (shouldResetTextColor) {
                textView.setTextColor(textColor);
            }
        }
    });
    return shakeAnim;
}
 
源代码4 项目: animation-samples   文件: TextResize.java
public TextResizeData(TextView textView) {
    this.paddingLeft = textView.getPaddingLeft();
    this.paddingTop = textView.getPaddingTop();
    this.paddingRight = textView.getPaddingRight();
    this.paddingBottom = textView.getPaddingBottom();
    this.width = textView.getWidth();
    this.height = textView.getHeight();
    this.gravity = textView.getGravity();
    this.textColor = textView.getCurrentTextColor();
}
 
源代码5 项目: Last-Launcher   文件: LauncherActivity.java
private void changeColorSize(String activityName, TextView view) {
    int color = DbUtils.getAppColor(activityName);
    if (color == DbUtils.NULL_TEXT_COLOR) {
        color = view.getCurrentTextColor();
    }

    int size = DbUtils.getAppSize(activityName);
    if (size == DbUtils.NULL_TEXT_SIZE) {
        for (Apps apps : mAppsList) {
            if (apps.getActivityName().equals(activityName)) {
                size = apps.getSize();
                break;
            }
        }
    }
    dialogs = new ColorSizeDialog(this, activityName, color, view, size);

    Window window = dialogs.getWindow();
    if (window != null) {
        window.setGravity(Gravity.BOTTOM);
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    }


    dialogs.show();
}
 
源代码6 项目: debugdrawer   文件: WatcherElement.java
@Override
public void run() {
	TextView view = parent.titleView;
	int currentColor = view.getCurrentTextColor();
	if (currentColor == originalColor) {
		view.setTextColor(flashColor);
	} else {
		view.setTextColor(originalColor);
	}

	handler.postDelayed(this, 1000);
}
 
源代码7 项目: restcomm-android-sdk   文件: BasicUITests.java
public static Matcher<View> withTextColor(final int color) {
    Checks.checkNotNull(color);
    return new BoundedMatcher<View, TextView>(TextView.class) {
        @Override
        public boolean matchesSafely(TextView textView) {
            return color == textView.getCurrentTextColor();
        }
        @Override
        public void describeTo(Description description) {
            description.appendText("Expected Color: " + color);
        }
    };
}
 
源代码8 项目: atlas   文件: TextResize.java
public TextResizeData(TextView textView) {
    this.paddingLeft = textView.getPaddingLeft();
    this.paddingTop = textView.getPaddingTop();
    this.paddingRight = textView.getPaddingRight();
    this.paddingBottom = textView.getPaddingBottom();
    this.width = textView.getWidth();
    this.height = textView.getHeight();
    this.gravity = textView.getGravity();
    this.textColor = textView.getCurrentTextColor();
}
 
源代码9 项目: android-instant-apps   文件: TextResize.java
public TextResizeData(TextView textView) {
    this.paddingLeft = textView.getPaddingLeft();
    this.paddingTop = textView.getPaddingTop();
    this.paddingRight = textView.getPaddingRight();
    this.paddingBottom = textView.getPaddingBottom();
    this.width = textView.getWidth();
    this.height = textView.getHeight();
    this.gravity = textView.getGravity();
    this.textColor = textView.getCurrentTextColor();
}
 
源代码10 项目: android-login   文件: TextSizeTransition.java
public TextResizeData(TextView textView) {
  this.paddingLeft = textView.getPaddingLeft();
  this.paddingTop = textView.getPaddingTop();
  this.paddingRight = textView.getPaddingRight();
  this.paddingBottom = textView.getPaddingBottom();
  this.width = textView.getWidth();
  this.height = textView.getHeight();
  this.gravity = textView.getGravity();
  this.textColor = textView.getCurrentTextColor();
}
 
源代码11 项目: friendspell   文件: CustomMatchers.java
public static Matcher<View> withTextColor(final int color) {
  return new BoundedMatcher<View, TextView>(TextView.class) {
    @Override public boolean matchesSafely(TextView textView) {
      return (textView.getCurrentTextColor() == color);
    }
    @Override public void describeTo(Description description) {
      description.appendText("has colors: " + getHexColor(color));
    }
  };
}
 
源代码12 项目: Scoops   文件: TestUtils.java
public static Matcher<View> withTextColor(final int color) {
    Checks.checkNotNull(color);
    return new BoundedMatcher<View, TextView>(TextView.class) {
        @Override
        public boolean matchesSafely(TextView warning) {
            return color == warning.getCurrentTextColor();
        }
        @Override
        public void describeTo(Description description) {
            description.appendText("with text color: ");
        }
    };
}
 
源代码13 项目: android-sliderview   文件: SlidingTabLayout.java
private View getCustomTabView(CharSequence title) {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View tabView = inflater.inflate(customTabViewId, strip, false);
    TextView text = (TextView) tabView.findViewById(customTabViewTextViewId);
    if (text != null) {
        text.setText(title);
        if (textColor == -1) textColor = text.getCurrentTextColor();
    }

    return tabView;
}
 
Builder(int id, @Nullable ViewHierarchyElementAndroid parent, View fromView) {
  // Bookkeeping
  this.id = id;
  this.parentId = (parent != null) ? parent.getId() : null;

  this.drawingOrder = null;

  // API 16+ properties
  this.scrollable = AT_16 ? fromView.isScrollContainer() : null;

  // API 11+ properties
  this.backgroundDrawableColor =
      (AT_11 && (fromView != null) && (fromView.getBackground() instanceof ColorDrawable))
          ? ((ColorDrawable) fromView.getBackground()).getColor()
          : null;

  // Base properties
  this.visibleToUser = ViewAccessibilityUtils.isVisibleToUser(fromView);
  this.className = fromView.getClass().getName();
  this.accessibilityClassName = null;
  this.packageName = fromView.getContext().getPackageName();
  this.resourceName =
      (fromView.getId() != View.NO_ID)
          ? ViewAccessibilityUtils.getResourceNameForView(fromView)
          : null;
  this.contentDescription = SpannableStringAndroid.valueOf(fromView.getContentDescription());
  this.enabled = fromView.isEnabled();
  if (fromView instanceof TextView) {
    TextView textView = (TextView) fromView;
    // Hint text takes precedence if no text is present.
    CharSequence text = textView.getText();
    if (TextUtils.isEmpty(text)) {
      text = textView.getHint();
    }
    this.text = SpannableStringAndroid.valueOf(text);
    this.textSize = textView.getTextSize();

    this.textColor = textView.getCurrentTextColor();
    this.typefaceStyle =
        (textView.getTypeface() != null) ? textView.getTypeface().getStyle() : null;
  } else {
    this.text = null;
    this.textSize = null;
    this.textColor = null;
    this.typefaceStyle = null;
  }

  this.importantForAccessibility = ViewAccessibilityUtils.isImportantForAccessibility(fromView);
  this.clickable = fromView.isClickable();
  this.longClickable = fromView.isLongClickable();
  this.focusable = fromView.isFocusable();
  this.editable = ViewAccessibilityUtils.isViewEditable(fromView);
  this.canScrollForward =
      (ViewCompat.canScrollVertically(fromView, 1)
          || ViewCompat.canScrollHorizontally(fromView, 1));
  this.canScrollBackward =
      (ViewCompat.canScrollVertically(fromView, -1)
          || ViewCompat.canScrollHorizontally(fromView, -1));
  this.checkable = (fromView instanceof Checkable);
  this.checked = (fromView instanceof Checkable) ? ((Checkable) fromView).isChecked() : null;
  this.hasTouchDelegate = (fromView.getTouchDelegate() != null);
  this.touchDelegateBounds = ImmutableList.of(); // Unavailable from the View API
  this.boundsInScreen = getBoundsInScreen(fromView);
  this.nonclippedHeight = fromView.getHeight();
  this.nonclippedWidth = fromView.getWidth();
  this.actionList = ImmutableList.of(); // Unavailable from the View API
}
 
源代码15 项目: HeadsUp   文件: NotificationWidget.java
/**
 * @return {@code true} if given {@link android.widget.TextView} have dark
 * color of text (average of RGB is lower than 127), {@code false} otherwise.
 */
protected boolean hasDarkTextColor(TextView textView) {
    int color = textView.getCurrentTextColor();
    return getAverageRgb(color) < 127;
}
 
源代码16 项目: VCL-Android   文件: PickTimeFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog_time_picker, container);
    mTVTimeToJump = (TextView) view.findViewById(R.id.tim_pic_timetojump);
    ((TextView)view.findViewById(R.id.tim_pic_title)).setText(getTitle());
    ((ImageView) view.findViewById(R.id.tim_pic_icon)).setImageResource(Util.getResourceFromAttribute(getActivity(), getIcon()));

    view.findViewById(R.id.tim_pic_1).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_1).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_2).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_2).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_3).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_3).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_4).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_4).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_5).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_5).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_6).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_6).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_7).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_7).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_8).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_8).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_9).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_9).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_0).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_0).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_00).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_00).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_30).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_30).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_cancel).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_cancel).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_delete).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_delete).setOnFocusChangeListener(this);
    view.findViewById(R.id.tim_pic_ok).setOnClickListener(this);
    view.findViewById(R.id.tim_pic_ok).setOnFocusChangeListener(this);

    mTextColor = mTVTimeToJump.getCurrentTextColor();

    getDialog().setCancelable(true);
    getDialog().setCanceledOnTouchOutside(true);
    if (getDialog() != null) {
        int dialogWidth = getResources().getDimensionPixelSize(R.dimen.dialog_time_picker_width);
        int dialogHeight = ViewGroup.LayoutParams.WRAP_CONTENT;
        getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
        getDialog().getWindow().setBackgroundDrawableResource(Util.getResourceFromAttribute(getActivity(), R.attr.rounded_bg));
    }
    return view;
}
 
源代码17 项目: 600SeriesAndroidUploader   文件: UserLogAdapter.java
private void initDrawables(TextView tv) {

        largeText = mContext.getResources().getConfiguration().fontScale > 1;

        int c = tv.getCurrentTextColor();
        float s = tv.getTextSize();

        float[] hsv = new float[3];
        Color.colorToHSV(c, hsv);

        int normal = c >> 24 & 0xFF;
        if (normal == 0xFF) normal = Color.HSVToColor(new float[] {0.f, 0.f, hsv[2]}) & 0xFF;
        int high = (int) (HIGHLIGHT *normal);
        int low = (int) (LOWLIGHT * normal);
        if (high > 0xFF) high = 0xFF;
        if (low > 0xFF) low = 0xFF;

        cNormal = Color.HSVToColor(normal, new float[] {hsv[0], hsv[1], 1.f});
        cHigh = Color.HSVToColor(high, new float[] {hsv[0], hsv[1], 1.f});
        cLow = Color.HSVToColor(low, new float[] {hsv[0], hsv[1], 1.f});

        Log.d(TAG, String.format("textColor: %08x textSize: %s normal: %08x high: %08x low: %08x", c, s, cNormal, cHigh, cLow));

        cEestimate = Color.HSVToColor(high, ESTIMATE_HSV);
        cIsig = Color.HSVToColor(normal, ISIG_HSV);
        cHistory = Color.HSVToColor(normal, HISTORY_HSV);
        cPushover = Color.HSVToColor(normal, PUSHOVER_HSV);

        iBounds = (int) (s * 1.2);
        iOffsetXDp = 0;
        iOffsetYDp = 3;

        iWARN = icon("ion_alert_circled", Color.HSVToColor(high, WARN_HSV));
        iINFO = icon("ion_information_circled", cHigh);
        iNOTE = icon("ion_document", Color.HSVToColor(high, NOTE_HSV));
        iHELP = icon("ion_ios_lightbulb", cHigh);
        iCGM = icon("ion_ios_pulse_strong", Color.HSVToColor(high, CGM_HSV));
        iHEART = icon("ion_heart", Color.HSVToColor(high, HEART_HSV));
        iSHARE = icon("ion_android_share_alt", Color.HSVToColor(normal, SHARE_HSV));
        iREFRESH = icon("ion_refresh", cNormal);
        iSETTING = icon("ion_android_settings", cHigh);

        init = true;
    }
 
源代码18 项目: react-native-navigation   文件: TextViewUtils.java
@ColorInt
public static int getTextColor(TextView view) {
    SpannedString text = new SpannedString(view.getText());
    ForegroundColorSpan[] spans = text.getSpans(0, text.length(), ForegroundColorSpan.class);
    return spans.length == 0 ? view.getCurrentTextColor() : spans[0].getForegroundColor();
}
 
/** Returns a matcher that matches TextViews with the specified text color. */
public static Matcher<View> withTextColor(final @ColorInt int textColor) {
  return new BoundedMatcher<View, TextView>(TextView.class) {
    private String failedCheckDescription;

    @Override
    public void describeTo(final Description description) {
      description.appendText(failedCheckDescription);
    }

    @Override
    public boolean matchesSafely(final TextView view) {
      final @ColorInt int ourTextColor = view.getCurrentTextColor();
      if (ourTextColor != textColor) {
        int ourAlpha = Color.alpha(ourTextColor);
        int ourRed = Color.red(ourTextColor);
        int ourGreen = Color.green(ourTextColor);
        int ourBlue = Color.blue(ourTextColor);

        int expectedAlpha = Color.alpha(textColor);
        int expectedRed = Color.red(textColor);
        int expectedGreen = Color.green(textColor);
        int expectedBlue = Color.blue(textColor);

        failedCheckDescription =
            "expected color to be ["
                + expectedAlpha
                + ","
                + expectedRed
                + ","
                + expectedGreen
                + ","
                + expectedBlue
                + "] but found ["
                + ourAlpha
                + ","
                + ourRed
                + ","
                + ourGreen
                + ","
                + ourBlue
                + "]";
        return false;
      }
      return true;
    }
  };
}
 
源代码20 项目: Scoops   文件: TextViewColorAdapter.java
@Override
public int getColor(TextView view) {
    return view.getCurrentTextColor();
}
 
 方法所在类
 同类方法