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

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

源代码1 项目: atlas   文件: DetailSharedElementEnterCallback.java
@Override
public void onSharedElementStart(List<String> sharedElementNames,
                                 List<View> sharedElements,
                                 List<View> sharedElementSnapshots) {
    TextView author = getAuthor();
    targetTextSize = author.getTextSize();
    targetTextColors = author.getTextColors();
    targetPadding = new Rect(author.getPaddingLeft(),
            author.getPaddingTop(),
            author.getPaddingRight(),
            author.getPaddingBottom());
    if (IntentUtil.INSTANCE.hasAll(intent,
            IntentUtil.INSTANCE.getTEXT_COLOR(), IntentUtil.INSTANCE.getFONT_SIZE(), IntentUtil.INSTANCE.getPADDING())) {
        author.setTextColor(intent.getIntExtra(IntentUtil.INSTANCE.getTEXT_COLOR(), Color.BLACK));
        float textSize = intent.getFloatExtra(IntentUtil.INSTANCE.getFONT_SIZE(), targetTextSize);
        author.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        Rect padding = intent.getParcelableExtra(IntentUtil.INSTANCE.getPADDING());
        author.setPadding(padding.left, padding.top, padding.right, padding.bottom);
    }
}
 
/** Returns a matcher that matches TextViews with the specified text size. */
public static Matcher<View> withTextSize(final float textSize) {
  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 float ourTextSize = view.getTextSize();
      if (Math.abs(textSize - ourTextSize) > 1.0f) {
        failedCheckDescription =
            "text size " + ourTextSize + " is different than expected " + textSize;
        return false;
      }
      return true;
    }
  };
}
 
源代码3 项目: commcare-android   文件: FormLayoutHelpers.java
private static int getNumberOfGroupLinesAllowed(TextView groupLabel,
                                                Rect newRootViewDimensions,
                                                FormEntryActivity activity) {
    int contentSize = newRootViewDimensions.height();
    View navBar = activity.findViewById(R.id.nav_pane);
    int headerSize = navBar.getHeight();
    if (headerSize == 0) {
        headerSize = activity.getResources().getDimensionPixelSize(R.dimen.new_progressbar_minheight);
    }

    int availableWindow = contentSize - headerSize - getActionBarSize(activity);

    // Request a consistent amount of the screen before groups can cut down
    int spaceRequested = getFontSizeInPx(activity) * 6;
    int spaceAvailable = availableWindow - spaceRequested;

    int defaultHeaderSpace =
            activity.getResources().getDimensionPixelSize(R.dimen.content_min_margin) * 2;

    float textSize = groupLabel.getTextSize();
    return Math.max(0, (int)((spaceAvailable - defaultHeaderSpace) / textSize));
}
 
源代码4 项目: PicKing   文件: SnackbarUtils.java
/**
 * 设置TextView(@+id/snackbar_text)左右两侧的图片
 *
 * @param leftDrawable
 * @param rightDrawable
 * @return
 */
public SnackbarUtils leftAndRightDrawable(@Nullable Drawable leftDrawable, @Nullable Drawable rightDrawable) {
    if (getSnackbar() != null) {
        TextView message = (TextView) getSnackbar().getView().findViewById(R.id.snackbar_text);
        LinearLayout.LayoutParams paramsMessage = (LinearLayout.LayoutParams) message.getLayoutParams();
        paramsMessage = new LinearLayout.LayoutParams(paramsMessage.width, paramsMessage.height, 0.0f);
        message.setLayoutParams(paramsMessage);
        message.setCompoundDrawablePadding(message.getPaddingLeft());
        int textSize = (int) message.getTextSize();
        if (leftDrawable != null) {
            leftDrawable.setBounds(0, 0, textSize, textSize);
        }
        if (rightDrawable != null) {
            rightDrawable.setBounds(0, 0, textSize, textSize);
        }
        message.setCompoundDrawables(leftDrawable, null, rightDrawable, null);
        LinearLayout.LayoutParams paramsSpace = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
        ((Snackbar.SnackbarLayout) getSnackbar().getView()).addView(new Space(getSnackbar().getView().getContext()), 1, paramsSpace);
    }
    return this;
}
 
源代码5 项目: CoolSignIn   文件: TextSharedElementCallback.java
@Override
public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements,
                                 List<View> sharedElementSnapshots) {
    TextView targetView = getTextView(sharedElements);
    if (targetView == null) {
        Log.w(TAG, "onSharedElementStart: No shared TextView, skipping.");
        return;
    }
    mTargetViewTextSize = targetView.getTextSize();
    mTargetViewPaddingStart = targetView.getPaddingStart();
    // Setup the TextView's start values.
    targetView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mInitialTextSize);
    ViewUtils.setPaddingStart(targetView, mInitialPaddingStart);
}
 
源代码6 项目: htmlview   文件: HtmlView.java
/**
 * Creates a HTML document widget.
 * 
 * @param requestHandler the object used for requesting resources (embedded images, links)
 * @param documentUrl document URL, used as base URL for resolving relative links
 */
public HtmlView(Context context) {
  super(context, null, false);
  // android.R.layout.simple_spinner_dropdown_item
  // android.R.layout.simple_list_item_1
  TextView tv = (TextView) LayoutInflater.from(context).inflate(android.R.layout.simple_spinner_dropdown_item, null,false); 
  
  pixelScale = tv.getTextSize() / 16f;
  Log.d("HtmlView", "TextView text size: " + tv.getTextSize() + " paint: " + tv.getPaint().getTypeface());
}
 
@Override
public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements,
                                 List<View> sharedElementSnapshots) {
    TextView targetView = getTextView(sharedElements);
    if (targetView == null) {
        Log.w(TAG, "onSharedElementStart: No shared TextView, skipping.");
        return;
    }
        mTargetViewTextSize = targetView.getTextSize();
        mTargetViewPaddingStart = targetView.getPaddingStart();
        // Setup the TextView's start values.
        targetView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mInitialTextSize);
        ViewUtils.setPaddingStart(targetView, mInitialPaddingStart);
}
 
源代码8 项目: AcDisplay   文件: Extractor.java
private void removeSubtextViews(@NonNull Context context,
                                @NonNull ArrayList<TextView> textViews) {
    float subtextSize = context.getResources().getDimension(R.dimen.notification_subtext_size);
    for (int i = textViews.size() - 1; i >= 0; i--) {
        final TextView child = textViews.get(i);
        final String text = child.getText().toString();
        if (child.getTextSize() == subtextSize
                // empty textviews
                || text.matches("^(\\s*|)$")
                // clock textviews
                || text.matches("^\\d{1,2}:\\d{1,2}(\\s?\\w{2}|)$")) {
            textViews.remove(i);
        }
    }
}
 
源代码9 项目: MVPAndroidBootstrap   文件: SearchViewUtil.java
/**
     * Sets the searchview's hint icon and text.
     *
     * @param searchView
     * @param drawableResource
     * @param hintText
     */
    public static void setSearchHintIcon(SearchView searchView, int drawableResource, String hintText) {
        try {
            // Accessing the SearchAutoComplete
            int queryTextViewId = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
            View autoComplete = searchView.findViewById(queryTextViewId);

            //Class<?> clazz = Class.forName("android.widget.SearchView$SearchAutoComplete");

            TextView searchBox = (TextView) searchView.findViewById(R.id.search_src_text);


            SpannableStringBuilder stopHint = new SpannableStringBuilder("   ");
            stopHint.append(hintText);

// Add the icon as an spannable
            Drawable searchIcon = searchView.getContext().getResources().getDrawable(drawableResource);
            Float rawTextSize = searchBox.getTextSize();
            int textSize = (int) (rawTextSize * 1.25);
            searchIcon.setBounds(0, 0, textSize, textSize);
            stopHint.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            // Set the new hint text
            searchBox.setHint(stopHint);
            //searchBox.setTextColor(Color.WHITE);
            searchBox.setHintTextColor(Color.LTGRAY);

        } catch (Exception e) {
            Log.e("SearchView", e.getMessage(), e);
        }
    }
 
源代码10 项目: OpenWeatherPlus-Android   文件: WeatherFragment.java
private void smallMid(List<TextView> tvList) {
    for (TextView textView : tvList) {
        float textSize = textView.getTextSize();
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 5 / 4);
    }
}
 
源代码11 项目: OpenWeatherPlus-Android   文件: WeatherFragment.java
private void largeSmall(List<TextView> tvList) {
    for (TextView textView : tvList) {
        float textSize = textView.getTextSize();
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 8 / 11);
    }
}
 
源代码12 项目: libcommon   文件: KeyboardView.java
/**
	 * コンストラクタ
	 * @param context
	 * @param attrs
	 * @param defStyleAttr
	 */
	public KeyboardView(@NonNull final Context context,
		@Nullable final AttributeSet attrs, final int defStyleAttr) {

		super(context, attrs, defStyleAttr);

		if (DEBUG) Log.v(TAG, "コンストラクタ:");
		final TypedArray a = context.getTheme().obtainStyledAttributes(
			attrs, R.styleable.KeyboardView, defStyleAttr, 0);

		final LayoutInflater inflate = LayoutInflater.from(context);
		final Resources resources = context.getResources();

		mKeyBackground = a.getDrawable(R.styleable.KeyboardView_keyBackground);
		if (DEBUG) Log.v(TAG, "コンストラクタ:mKeyBackground=" + mKeyBackground);
		mVerticalCorrection = a.getDimensionPixelOffset( R.styleable.KeyboardView_verticalCorrection, 0);
		if (DEBUG) Log.v(TAG, "コンストラクタ:mVerticalCorrection=" + mVerticalCorrection);
		int previewLayout = a.getResourceId(R.styleable.KeyboardView_keyPreviewLayout, 0);
		if (DEBUG) Log.v(TAG, "コンストラクタ:previewLayout=" + previewLayout);
		mPreviewOffset = a.getDimensionPixelOffset(R.styleable.KeyboardView_keyPreviewOffset, 0);
		if (DEBUG) Log.v(TAG, "コンストラクタ:mPreviewOffset=" + mPreviewOffset);
		mPreviewHeight = a.getDimensionPixelSize(R.styleable.KeyboardView_keyPreviewHeight,
			resources.getDimensionPixelSize(R.dimen.keyboard_key_preview_height));
		if (DEBUG) Log.v(TAG, "コンストラクタ:mPreviewHeight=" + mPreviewHeight);
		mKeyTextSize = a.getDimension(R.styleable.KeyboardView_keyTextSize,
			resources.getDimension(R.dimen.keyboard_key_text_sz));
		if (DEBUG) Log.v(TAG, "コンストラクタ:mKeyTextSize=" + mKeyTextSize);

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
			mKeyTextColor = a.getColor(R.styleable.KeyboardView_keyTextColor,
				resources.getColor(R.color.keyboard_key_text_color, null));
			mLabelTextColor = a.getColor(R.styleable.KeyboardView_labelTextColor,
				resources.getColor(R.color.keyboard_key_label_color, null));
			mShadowColor = a.getColor(R.styleable.KeyboardView_shadowColor,
				resources.getColor(R.color.keyboard_key_label_color, null));
		} else {
			mKeyTextColor = a.getColor(R.styleable.KeyboardView_keyTextColor,
				resources.getColor(R.color.keyboard_key_text_color));
			mLabelTextColor = a.getColor(R.styleable.KeyboardView_labelTextColor,
				resources.getColor(R.color.keyboard_key_label_color));
			mShadowColor = a.getColor(R.styleable.KeyboardView_shadowColor,
				resources.getColor(R.color.keyboard_key_label_color));
		}
		if (DEBUG) Log.v(TAG, String.format("コンストラクタ:mKeyTextColor=%08x", mKeyTextColor));
		if (DEBUG) Log.v(TAG, String.format("コンストラクタ:mLabelTextColor=%08x", mLabelTextColor));
		if (DEBUG) Log.v(TAG, String.format("コンストラクタ:mShadowColor=%08x", mShadowColor));
		mLabelTextSize = a.getDimension(R.styleable.KeyboardView_labelTextSize,
			resources.getDimension(R.dimen.keyboard_label_sz));
		if (DEBUG) Log.v(TAG, "コンストラクタ:mLabelTextSize=" + mLabelTextSize);
		mPopupLayout = a.getResourceId(R.styleable.KeyboardView_popupLayout, 0);
		if (DEBUG) Log.v(TAG, "コンストラクタ:mPopupLayout=" + mPopupLayout);
		mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f);
		if (DEBUG) Log.v(TAG, "コンストラクタ:mShadowRadius=" + mShadowRadius);
		a.recycle();

		mPreviewPopup = new PopupWindow(context);
		if (previewLayout != 0) {
			mPreviewText = (TextView) inflate.inflate(previewLayout, null);
			mPreviewTextSizeLarge = (int) mPreviewText.getTextSize();
			mPreviewPopup.setContentView(mPreviewText);
			mPreviewPopup.setBackgroundDrawable(null);
		} else {
			mShowPreview = false;
		}

		mPreviewPopup.setTouchable(false);

		mPopupKeyboard = new PopupWindow(context);
		mPopupKeyboard.setBackgroundDrawable(null);
		//mPopupKeyboard.setClippingEnabled(false);

		mPopupParent = this;
		//mPredicting = true;

		mPaint = new Paint();
		mPaint.setAntiAlias(true);
		mPaint.setTextSize(0);
		mPaint.setTextAlign(Paint.Align.CENTER);
		mPaint.setAlpha(255);

		mPadding = new Rect(0, 0, 0, 0);
		mMiniKeyboardCache = new HashMap<Keyboard.Key, View>();
		mKeyBackground.getPadding(mPadding);

		mSwipeThreshold = (int) (500 * getResources().getDisplayMetrics().density);
		mDisambiguateSwipe = getResources().getBoolean(R.bool.config_swipeDisambiguation);

		mAccessibilityManager
			= ContextUtils.requireSystemService(context, AccessibilityManager.class);
//		mAudioManager = ContextUtils.requireSystemService(context, AudioManager.class);

		resetMultiTap();
	}
 
源代码13 项目: BigApp_Discuz_Android   文件: MessageUtils.java
/**
     * 粗处理标题,若有分类,此方法决定分类样式
     *
     * @param context
     * @param urlColor
     * @return
     */
    public static void setTextSpan(final Context context, TextView textView, final String text, int urlColor) {
        String content = text;
        if (StringUtils.isEmptyOrNullOrNullStr(content)) {
            content = context.getString(R.string.default_value);
        }

//        SpannableStringBuilder ssb = DefEmoticons.replaceUnicodeByEmoji(context, content);
        int textSize = (int) textView.getTextSize();

        SpannableStringBuilder ssb = getEmoticon(context, content, textSize);

        ssb = getURLSSB(context, ssb, urlColor);


        textView.setText(ssb);
        textView.setMovementMethod(LinkMovementMethod.getInstance());

    }
 
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 项目: Telegram-FOSS   文件: NumberPicker.java
private void init() {
    mSolidColor = 0;
    mSelectionDivider = new Paint();
    mSelectionDivider.setColor(Theme.getColor(Theme.key_dialogButton));

    mSelectionDividerHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDER_HEIGHT, getResources().getDisplayMetrics());
    mSelectionDividersDistance = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDERS_DISTANCE, getResources().getDisplayMetrics());

    mMinHeight = SIZE_UNSPECIFIED;

    mMaxHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, getResources().getDisplayMetrics());
    if (mMinHeight != SIZE_UNSPECIFIED && mMaxHeight != SIZE_UNSPECIFIED && mMinHeight > mMaxHeight) {
        throw new IllegalArgumentException("minHeight > maxHeight");
    }

    mMinWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, getResources().getDisplayMetrics());

    mMaxWidth = SIZE_UNSPECIFIED;
    if (mMinWidth != SIZE_UNSPECIFIED && mMaxWidth != SIZE_UNSPECIFIED && mMinWidth > mMaxWidth) {
        throw new IllegalArgumentException("minWidth > maxWidth");
    }

    mComputeMaxWidth = (mMaxWidth == SIZE_UNSPECIFIED);

    mPressedStateHelper = new PressedStateHelper();

    setWillNotDraw(false);

    mInputText = new TextView(getContext());
    mInputText.setGravity(Gravity.CENTER);
    mInputText.setSingleLine(true);
    mInputText.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    mInputText.setBackgroundResource(0);
    mInputText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    mInputText.setVisibility(INVISIBLE);
    addView(mInputText, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity() / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    mTextSize = (int) mInputText.getTextSize();

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(mTextSize);
    paint.setTypeface(mInputText.getTypeface());
    ColorStateList colors = mInputText.getTextColors();
    int color = colors.getColorForState(ENABLED_STATE_SET, Color.WHITE);
    paint.setColor(color);
    mSelectorWheelPaint = paint;

    mFlingScroller = new Scroller(getContext(), null, true);
    mAdjustScroller = new Scroller(getContext(), new DecelerateInterpolator(2.5f));

    updateInputTextView();
}
 
源代码16 项目: TelePlus-Android   文件: NumberPicker.java
private void init() {
    mSolidColor = 0;
    mSelectionDivider = new Paint();
    mSelectionDivider.setColor(Theme.getColor(Theme.key_dialogButton));

    mSelectionDividerHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDER_HEIGHT, getResources().getDisplayMetrics());
    mSelectionDividersDistance = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, UNSCALED_DEFAULT_SELECTION_DIVIDERS_DISTANCE, getResources().getDisplayMetrics());

    mMinHeight = SIZE_UNSPECIFIED;

    mMaxHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, getResources().getDisplayMetrics());
    if (mMinHeight != SIZE_UNSPECIFIED && mMaxHeight != SIZE_UNSPECIFIED && mMinHeight > mMaxHeight) {
        throw new IllegalArgumentException("minHeight > maxHeight");
    }

    mMinWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64, getResources().getDisplayMetrics());

    mMaxWidth = SIZE_UNSPECIFIED;
    if (mMinWidth != SIZE_UNSPECIFIED && mMaxWidth != SIZE_UNSPECIFIED && mMinWidth > mMaxWidth) {
        throw new IllegalArgumentException("minWidth > maxWidth");
    }

    mComputeMaxWidth = (mMaxWidth == SIZE_UNSPECIFIED);

    mPressedStateHelper = new PressedStateHelper();

    setWillNotDraw(false);

    mInputText = new TextView(getContext());
    mInputText.setGravity(Gravity.CENTER);
    mInputText.setSingleLine(true);
    mInputText.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    mInputText.setBackgroundResource(0);
    mInputText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    addView(mInputText, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity() / SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT;
    mTextSize = (int) mInputText.getTextSize();

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(mTextSize);
    paint.setTypeface(mInputText.getTypeface());
    ColorStateList colors = mInputText.getTextColors();
    int color = colors.getColorForState(ENABLED_STATE_SET, Color.WHITE);
    paint.setColor(color);
    mSelectorWheelPaint = paint;

    mFlingScroller = new Scroller(getContext(), null, true);
    mAdjustScroller = new Scroller(getContext(), new DecelerateInterpolator(2.5f));

    updateInputTextView();
}
 
源代码17 项目: playa   文件: BottomNavigationViewEx.java
/**
     * change the visibility of text
     *
     * @param visibility
     */
    public void setTextVisibility(boolean visibility) {
        this.textVisibility = visibility;
        /*
        1. get field in this class
        private final BottomNavigationMenuView mMenuView;

        2. get field in mButtons
        private BottomNavigationItemView[] mButtons;

        3. set text size in mButtons
        private final TextView mLargeLabel
        private final TextView mSmallLabel

        4. change mItemHeight to only icon size in mMenuView
         */
        // 1. get mMenuView
        BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
        // 2. get mButtons
        BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();

        // 3. change field mShiftingMode value in mButtons
        for (BottomNavigationItemView button : mButtons) {
            TextView mLargeLabel = getField(button.getClass(), button, "mLargeLabel");
            TextView mSmallLabel = getField(button.getClass(), button, "mSmallLabel");

            if (!visibility) {
                // if not record the font size, record it
                if (!visibilityTextSizeRecord && !animationRecord) {
                    visibilityTextSizeRecord = true;
                    mLargeLabelSize = mLargeLabel.getTextSize();
                    mSmallLabelSize = mSmallLabel.getTextSize();
                }

                // if not visitable, set font size to 0
                mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0);
                mSmallLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0);

            } else {
                // if not record the font size, we need do nothing.
                if (!visibilityTextSizeRecord)
                    break;

                // restore it
                mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLargeLabelSize);
                mSmallLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mSmallLabelSize);
            }
        }

        // 4 change mItemHeight to only icon size in mMenuView
        if (!visibility) {
            // if not record mItemHeight
            if (!visibilityHeightRecord) {
                visibilityHeightRecord = true;
                mItemHeight = getItemHeight();
            }

            // change mItemHeight to only icon size in mMenuView
            // private final int mItemHeight;

            // change mItemHeight
//            System.out.println("mLargeLabel.getMeasuredHeight():" + getFontHeight(mSmallLabelSize));
            setItemHeight(mItemHeight - getFontHeight(mSmallLabelSize));

        } else {
            // if not record the mItemHeight, we need do nothing.
            if (!visibilityHeightRecord)
                return;
            // restore mItemHeight
            setItemHeight(mItemHeight);
        }

        mMenuView.updateMenuView();
    }
 
/**
     * enable or disable click item animation(text scale and icon move animation in no item shifting mode)
     *
     * @param enable It means the text won't scale and icon won't move when active it in no item shifting mode if false.
     */
    public BottomNavigationViewInner enableAnimation(boolean enable) {
        /*
        1. get field in this class
        private final BottomNavigationMenuView mMenuView;

        2. get field in mButtons
        private BottomNavigationItemView[] mButtons;

        3. chang mShiftAmount to 0 in mButtons
        private final int mShiftAmount

        change mScaleUpFactor and mScaleDownFactor to 1f in mButtons
        private final float mScaleUpFactor
        private final float mScaleDownFactor

        4. change label font size in mButtons
        private final TextView mLargeLabel
        private final TextView mSmallLabel
         */

        // 1. get mMenuView
        BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
        // 2. get mButtons
        BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
        // 3. change field mShiftingMode value in mButtons
        for (BottomNavigationItemView button : mButtons) {
            TextView mLargeLabel = getField(button.getClass(), button, "largeLabel");
            TextView mSmallLabel = getField(button.getClass(), button, "smallLabel");

            // if disable animation, need animationRecord the source value
            if (!enable) {
                if (!animationRecord) {
                    animationRecord = true;
                    mShiftAmount = getField(button.getClass(), button, "shiftAmount");
                    mScaleUpFactor = getField(button.getClass(), button, "scaleUpFactor");
                    mScaleDownFactor = getField(button.getClass(), button, "scaleDownFactor");

                    mLargeLabelSize = mLargeLabel.getTextSize();
                    mSmallLabelSize = mSmallLabel.getTextSize();

//                    System.out.println("mShiftAmount:" + mShiftAmount + " mScaleUpFactor:"
//                            + mScaleUpFactor + " mScaleDownFactor:" + mScaleDownFactor
//                            + " mLargeLabel:" + mLargeLabelSize + " mSmallLabel:" + mSmallLabelSize);
                }
                // disable
                setField(button.getClass(), button, "shiftAmount", 0);
                setField(button.getClass(), button, "scaleUpFactor", 1);
                setField(button.getClass(), button, "scaleDownFactor", 1);

                // let the mLargeLabel font size equal to mSmallLabel
                mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mSmallLabelSize);

                // debug start
//                mLargeLabelSize = mLargeLabel.getTextSize();
//                System.out.println("mLargeLabel:" + mLargeLabelSize);
                // debug end

            } else {
                // haven't change the value. It means it was the first call this method. So nothing need to do.
                if (!animationRecord)
                    return this;
                // enable animation
                setField(button.getClass(), button, "shiftAmount", mShiftAmount);
                setField(button.getClass(), button, "scaleUpFactor", mScaleUpFactor);
                setField(button.getClass(), button, "scaleDownFactor", mScaleDownFactor);
                // restore
                mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLargeLabelSize);
            }
        }
        mMenuView.updateMenuView();
        return this;
    }
 
源代码19 项目: YcShareElement   文件: ChangeTextTransition.java
@Override
public Float get(TextView object) {
    return object.getTextSize();
}
 
源代码20 项目: Cashew   文件: BottomNavigationViewEx.java
/**
     * change the visibility of text
     *
     * @param visibility
     */
    public void setTextVisibility(boolean visibility) {
        /*
        1. get field in this class
        private final BottomNavigationMenuView mMenuView;

        2. get field in mButtons
        private BottomNavigationItemView[] mButtons;

        3. set text size in mButtons
        private final TextView mLargeLabel
        private final TextView mSmallLabel

        4. change mItemHeight to only icon size in mMenuView
         */
        // 1. get mMenuView
        BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
        // 2. get mButtons
        BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
        // 3. change field mShiftingMode value in mButtons
        for (BottomNavigationItemView button : mButtons) {
            TextView mLargeLabel = getField(button.getClass(), button, "mLargeLabel");
            TextView mSmallLabel = getField(button.getClass(), button, "mSmallLabel");

            if (!visibility) {
                // if not record the font size, record it
                if (!visibilityTextSizeRecord && !animationRecord) {
                    visibilityTextSizeRecord = true;
                    mLargeLabelSize = mLargeLabel.getTextSize();
                    mSmallLabelSize = mSmallLabel.getTextSize();
                }

                // if not visitable, set font size to 0
                mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0);
                mSmallLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0);

            } else {
                // if not record the font size, we need do nothing.
                if (!visibilityTextSizeRecord)
                    break;

                // restore it
                mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLargeLabelSize);
                mSmallLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mSmallLabelSize);
            }
        }

        // 4 change mItemHeight to only icon size in mMenuView
        if (!visibility) {
            // if not record mItemHeight
            if (!visibilityHeightRecord) {
                visibilityHeightRecord = true;
                mItemHeight = getItemHeight();
            }

            // change mItemHeight to only icon size in mMenuView
            // private final int mItemHeight;

            // change mItemHeight
//            System.out.println("mLargeLabel.getMeasuredHeight():" + getFontHeight(mSmallLabelSize));
            setItemHeight(mItemHeight - getFontHeight(mSmallLabelSize));

        } else {
            // if not record the mItemHeight, we need do nothing.
            if (!visibilityHeightRecord)
                return;
            // restore mItemHeight
            setItemHeight(mItemHeight);
        }

        mMenuView.updateMenuView();
    }
 
 方法所在类
 同类方法