TextView  加下划线 、 中划线

下过如图:

TextView划线  android

 

// 中划线

textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰

// 下划线

textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);


//取消设置的线

textView.getPaint().setFlags(0); // 取消设置的的划线


我封装了几个方法  直接调用

 

	/**
	 * 下划线
	 * 
	 * @param textView
	 */
	private void addButtomLine(TextView textView) {
		textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
	}

	/**
	 * 移除线
	 * 
	 * @param textView
	 */
	private void removeLine(TextView textView) {
		textView.getPaint().setFlags(0); // 取消设置的的划线

	}

	/**
	 * 设置中划线并加清晰
	 * 
	 * @param textView
	 */
	private void addLine(TextView textView) {
		textView.getPaint().setFlags(
				Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰

	}

	/**
	 * 中划线
	 * 
	 * @param textView
	 */
	private void addCenterLine(TextView textView) {
		textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); // 中划线
	}

	/**
	 * 抗锯齿
	 * 
	 * @param textView
	 */
	private void addjuchiLine(TextView textView) {
		textView.getPaint().setAntiAlias(true);// 抗锯齿
	}


 

相关文章:

  • 2022-12-23
  • 2021-12-14
  • 2021-12-27
  • 2022-01-29
  • 2021-10-29
  • 2021-07-23
  • 2022-12-23
  • 2021-07-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案