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

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

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

TextView.getRotation介绍

暂无

代码示例

代码示例来源:origin: MZCretin/RelativeLayoutDemo

@Override
  public void onClick(View v) {
    String content = editText.getText().toString();
    if ( TextUtils.isEmpty(content) ) {
      Toast.makeText(context, "您没有任何输入!", Toast.LENGTH_SHORT).show();
    } else {
      if ( isNew ) {
        addTextView(null, currentX, currentY, content, colors[0], 0, 0);
      } else {
        addTextView(textView, textView.getX(), textView.getY(), content, colors[0], textView.getTextSize(), textView.getRotation());
      }
    }
    dialog.dismiss();
  }
});

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

private Region createRotatedRegion(TextView textView){
  Matrix matrix = new Matrix();
  matrix.setRotate(textView.getRotation(), textView.getX() + textView.getMeasuredWidth() / 2, textView.getY() + textView.getMeasuredHeight() / 2);

  Path path = new Path();
  Point LT = rotatePoint(matrix, textView.getX(), textView.getY());
  Point RT = rotatePoint(matrix, textView.getX() + textView.getMeasuredWidth(), textView.getY());
  Point RB = rotatePoint(matrix, textView.getX() + textView.getMeasuredWidth(), textView.getY() + textView.getMeasuredHeight());
  Point LB = rotatePoint(matrix, textView.getX(), textView.getY() + textView.getMeasuredHeight());

  path.moveTo(LT.x, LT.y);
  path.lineTo(RT.x, RT.y);
  path.lineTo(RB.x, RB.y);
  path.lineTo(LB.x, LB.y);

  Region region = new Region();
  region.setPath(path,  new Region(0, 0, textViewParent.getWidth(), textViewParent.getHeight()));
  return region;
}

private Point rotatePoint(Matrix matrix, float x, float y){
  float[] pts = new float[2];
  pts[0] = x;
  pts[1] = y;
  matrix.mapPoints(pts);
  return new Point((int)pts[0], (int)pts[1]);
}

相关文章

TextView类方法