android.widget.TextView.getPaint()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(289)

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

TextView.getPaint介绍

暂无

代码示例

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

TextView secondTextView = new TextView(this);
 Shader textShader=new LinearGradient(0, 0, 0, 20,
     new int[]{Color.GREEN,Color.BLUE},
     new float[]{0, 1}, TileMode.CLAMP);
 secondTextView.getPaint().setShader(textShader);

代码示例来源:origin: H07000223/FlycoTabLayout

private void updateTabSelection(int position) {
  for (int i = 0; i < mTabCount; ++i) {
    View tabView = mTabsContainer.getChildAt(i);
    final boolean isSelect = i == position;
    TextView tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
    tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor);
    if (mTextBold == TEXT_BOLD_WHEN_SELECT) {
      tab_title.getPaint().setFakeBoldText(isSelect);
    }
  }
}

代码示例来源:origin: H07000223/FlycoTabLayout

private void updateTabSelection(int position) {
  for (int i = 0; i < mTabCount; ++i) {
    View tabView = mTabsContainer.getChildAt(i);
    final boolean isSelect = i == position;
    TextView tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
    if (tab_title != null) {
      tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor);
      if (mTextBold == TEXT_BOLD_WHEN_SELECT) {
        tab_title.getPaint().setFakeBoldText(isSelect);
      }
    }
  }
}

代码示例来源:origin: H07000223/FlycoTabLayout

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
      View tabView = mTabsContainer.getChildAt(i);
      tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
      TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
      tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
      tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
//            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
      if (mTextAllCaps) {
        tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
      }

      if (mTextBold == TEXT_BOLD_BOTH) {
        tv_tab_title.getPaint().setFakeBoldText(true);
      } else if (mTextBold == TEXT_BOLD_NONE) {
        tv_tab_title.getPaint().setFakeBoldText(false);
      }
    }
  }

代码示例来源:origin: H07000223/FlycoTabLayout

private void updateTabSelection(int position) {
  for (int i = 0; i < mTabCount; ++i) {
    View tabView = mTabsContainer.getChildAt(i);
    final boolean isSelect = i == position;
    TextView tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
    tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor);
    ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
    CustomTabEntity tabEntity = mTabEntitys.get(i);
    iv_tab_icon.setImageResource(isSelect ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
    if (mTextBold == TEXT_BOLD_WHEN_SELECT) {
      tab_title.getPaint().setFakeBoldText(isSelect);
    }
  }
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 设置左上文字字体为粗体
 *
 * @return SuperTextView
 */
public SuperTextView setLeftTopTextIsBold(boolean isBold) {
  if (leftView != null) {
    leftView.getTopTextView().getPaint().setFakeBoldText(isBold);
  }
  return this;
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 设置左中文字字体为粗体
 *
 * @return SuperTextView
 */
public SuperTextView setLeftTextIsBold(boolean isBold) {
  if (leftView != null) {
    leftView.getCenterTextView().getPaint().setFakeBoldText(isBold);
  }
  return this;
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 设置右上文字字体为粗体
 *
 * @return SuperTextView
 */
public SuperTextView setRightTopTextIsBold(boolean isBold) {
  if (rightView != null) {
    rightView.getTopTextView().getPaint().setFakeBoldText(isBold);
  }
  return this;
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 设置中下文字字体为粗体
 *
 * @return SuperTextView
 */
public SuperTextView setCenterBottomTextIsBold(boolean isBold) {
  if (centerView != null) {
    centerView.getBottomTextView().getPaint().setFakeBoldText(isBold);
  }
  return this;
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 设置中中文字字体为粗体
 *
 * @return SuperTextView
 */
public SuperTextView setCenterTextIsBold(boolean isBold) {
  if (centerView != null) {
    centerView.getCenterTextView().getPaint().setFakeBoldText(isBold);
  }
  return this;
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 设置中上文字字体为粗体
 *
 * @return SuperTextView
 */
public SuperTextView setCenterTopTextIsBold(boolean isBold) {
  if (centerView != null) {
    centerView.getTopTextView().getPaint().setFakeBoldText(isBold);
  }
  return this;
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 设置右下文字字体为粗体
 *
 * @return SuperTextView
 */
public SuperTextView setRightBottomTextIsBold(boolean isBold) {
  if (rightView != null) {
    rightView.getBottomTextView().getPaint().setFakeBoldText(isBold);
  }
  return this;
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 设置左下文字字体为粗体
 *
 * @return SuperTextView
 */
public SuperTextView setLeftBottomTextIsBold(boolean isBold) {
  if (leftView != null) {
    leftView.getBottomTextView().getPaint().setFakeBoldText(isBold);
  }
  return this;
}

代码示例来源:origin: lygttpod/SuperTextView

/**
 * 设置右中文字字体为粗体
 *
 * @return SuperTextView
 */
public SuperTextView setRightTextIsBold(boolean isBold) {
  if (rightView != null) {
    rightView.getCenterTextView().getPaint().setFakeBoldText(isBold);
  }
  return this;
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

private void measureTabLayoutTextWidth(int position) {
  String title = titles.get(position);
  TextView titleView = mSlidingTabLayout.getTitleView(position);
  TextPaint paint = titleView.getPaint();
  float textWidth = paint.measureText(title);
  mSlidingTabLayout.setIndicatorWidth(textWidth / 3);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

private void measureTabLayoutTextWidth(int position) {
  String title = titles.get(position);
  TextView titleView = mSlidingTabLayout.getTitleView(position);
  TextPaint paint = titleView.getPaint();
  float textWidth = paint.measureText(title);
  mSlidingTabLayout.setIndicatorWidth(textWidth / 3);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

public void measureTabLayoutTextWidth(int position) {
  String titleName = titles.get(position);
  TextView titleView = mSlidingTab.getTitleView(position);
  TextPaint paint = titleView.getPaint();
  float v = paint.measureText(titleName);
  mSlidingTab.setIndicatorWidth(v / 3);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

private void measureTabLayoutTextWidth(int position) {
  String title = titles.get(position);
  TextView titleView = mSlidingTabLayout.getTitleView(position);
  TextPaint paint = titleView.getPaint();
  float textWidth = paint.measureText(title);
  mSlidingTabLayout.setIndicatorWidth(textWidth / 3);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getPaint_returnsNonNull() {
 assertNotNull(textView.getPaint());
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getPaint_returnsMeasureTextEnabledObject() throws Exception {
 assertThat(textView.getPaint().measureText("12345")).isEqualTo(5f);
}

相关文章

TextView类方法