/** Resize text after measuring */ @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if (changed || mNeedsResize) { int widthLimit = (right - left) - getCompoundPaddingLeft() - getCompoundPaddingRight(); int heightLimit = (bottom - top) - getCompoundPaddingBottom() - getCompoundPaddingTop(); resizeText(widthLimit, heightLimit); } super.onLayout(changed, left, top, right, bottom); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if (!isInitHeight) { // 因为给每行设置了间隙,所以之前测量的高度是小于我们整个文字的高度,需要把高度重新设置。 isInitHeight = true; textShowWidth = getWidth(); // 一定要在Measure之后获取宽度,否则获取不到,但Measure会执行多次,所以在onLayout之前获取 splitLines(); isInitDraw = true; } super.onLayout(changed, left, top, right, bottom); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (changed) { TextPaint paint = getPaint(); paint.setShader( new LinearGradient( 0, 0, 0, getHeight(), Color.parseColor("#2d9ed1"), Color.parseColor("#0e63ad"), Shader.TileMode.CLAMP)); } }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); wordPositions = getWordPositions(getTextLeftXCoord(getX())); wordWidths = getWordWidths(); charPositions = getCharPositions(getTextLeftXCoord(getX())); sentenceRightXPos = getTextLeftXCoord(getX()) + getPaint().measureText((String) getText()); sentenceLeftXPos = getTextLeftXCoord(getX()); // LayoutParams sbvLayoutParams = seekBar.getLayoutParams(); // int margin = (int) // TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0, // getResources().getDisplayMetrics()); // int width = getTextWidth() + 2 * margin; // sbvLayoutParams.width = width; // seekBar.setLayoutParams(sbvLayoutParams); // seekBar.setMax(width); // parentLayout.addView(seekBar); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); resize(); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); initMaxScrollAndCheckFrezon(); }
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { setGravity(Gravity.CENTER); super.onLayout(changed, left, top, right, bottom); }