本文整理了Java中android.widget.HorizontalScrollView.onDraw()
方法的一些代码示例,展示了HorizontalScrollView.onDraw()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HorizontalScrollView.onDraw()
方法的具体详情如下:
包路径:android.widget.HorizontalScrollView
类名称:HorizontalScrollView
方法名:onDraw
暂无
代码示例来源:origin: JohnPersano/SuperToasts
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode() || tabCount == 0) {
return;
}
final int height = getHeight();
// draw indicator line
rectPaint.setColor(indicatorColor);
// default: line below current tab
View currentTab = tabsContainer.getChildAt(currentPosition);
float lineLeft = currentTab.getLeft();
lineLeft += indicatorPadding;
float lineRight = currentTab.getRight();
lineRight -= indicatorPadding;
// if there is an offset, start interpolating left and right coordinates between current and next tab
if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
View nextTab = tabsContainer.getChildAt(currentPosition + 1);
float nextTabLeft = nextTab.getLeft();
nextTabLeft += indicatorPadding;
float nextTabRight = nextTab.getRight();
nextTabRight -= indicatorPadding;
lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
}
canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height - underlineHeight, rectPaint);
// draw underline
rectPaint.setColor(underlineColor);
canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);
}
代码示例来源:origin: joyoyao/superCleanMaster
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: H07000223/FlycoTabLayout
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: guolindev/giffun
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: tianshaojie/AndroidFine
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: ATHBK/UltimateTabLayout
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
try {
if (!tabModel.isTabUnderLineShow()) return;
int count = containerView.getChildCount();
View currentChildView = containerView.getChildAt(current);
float left = currentChildView.getLeft();
float right = currentChildView.getRight();
int width = currentChildView.getWidth();
int height = currentChildView.getHeight();
// Log.e("TAG", "Left: " + left + "/right: " + right + "/width: " + width + "/height: " + height);
if (positionOffSet > 0f && current < count - 1) {
final float nextTabLeft = left + width;
left = positionOffSet * nextTabLeft + (1f - positionOffSet) * left;
right = left + width;
}
canvas.drawRect(left, height - tabModel.getTabHeightUnderLine(), right, height, mPaintUnderLine);
} catch (NullPointerException e){
e.printStackTrace();
}
}
代码示例来源:origin: CarlLu/MVPframe
@Override
protected void onDraw(Canvas canvas) {
super.onDraw (canvas);
if (isInEditMode () || tabCount == 0) {
return;
}
final int height = getHeight ();
rectPaint.setColor (indicatorColor);
View currentTab = tabsContainer.getChildAt (currentPosition);
float lineLeft = currentTab.getLeft ();
float lineRight = currentTab.getRight ();
if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
View nextTab = tabsContainer.getChildAt (currentPosition + 1);
final float nextTabLeft = nextTab.getLeft ();
final float nextTabRight = nextTab.getRight ();
lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
}
canvas.drawRect (lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
rectPaint.setColor (underlineColor);
canvas.drawRect (0, height - underlineHeight, tabsContainer.getWidth (), height, rectPaint);
dividerPaint.setColor (dividerColor);
for (int i = 0; i < tabCount - 1; i++) {
View tab = tabsContainer.getChildAt (i);
canvas.drawLine (tab.getRight (), dividerPadding, tab.getRight (), height - dividerPadding, dividerPaint);
}
}
代码示例来源:origin: Hankkin/TaoSchool
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: Qiang3570/PageSlidingTab
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode() || tabCount == 0) {
return;
}
final int height = getHeight();
rectPaint.setColor(indicatorColor);
View currentTab = tabsContainer.getChildAt(currentPosition);
float lineLeft = currentTab.getLeft();
float lineRight = currentTab.getRight();
if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
View nextTab = tabsContainer.getChildAt(currentPosition + 1);
final float nextTabLeft = nextTab.getLeft();
final float nextTabRight = nextTab.getRight();
lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
}
canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
rectPaint.setColor(underlineColor);
canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);
dividerPaint.setColor(dividerColor);
for (int i = 0; i < tabCount - 1; i++) {
View tab = tabsContainer.getChildAt(i);
canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
}
}
代码示例来源:origin: CarGuo/linkagescroll
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: devinhu/androidone
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: brucetoo/GradientTabStrip
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: zxfnicholas/CameraSDK
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: kaku2015/WeatherAlarmClock
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: moz1q1/WalleLibrary
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode() || mTabCount == 0) {
return;
}
final int height = getHeight();
// draw divider
if (mDividerWidth > 0) {
mDividerPaint.setStrokeWidth(mDividerWidth);
mDividerPaint.setColor(mDividerColor);
for (int i = 0; i < mTabCount - 1; i++) {
View tab = mTabsContainer.getChildAt(i);
canvas.drawLine(tab.getRight(), mDividerPadding, tab.getRight(), height - mDividerPadding, mDividerPaint);
}
}
// draw underline
if (mUnderlineHeight > 0) {
mRectPaint.setColor(mUnderlineColor);
canvas.drawRect(mPaddingLeft, height - mUnderlineHeight, mTabsContainer.getWidth() + mPaddingRight, height, mRectPaint);
}
// draw indicator line
if (mIndicatorHeight > 0) {
mRectPaint.setColor(mIndicatorColor);
Pair<Float, Float> lines = getIndicatorCoordinates();
canvas.drawRect(lines.first + mPaddingLeft, height - mIndicatorHeight, lines.second + mPaddingLeft, height, mRectPaint);
}
}
代码示例来源:origin: BiglySoftware/BiglyBT-Android
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode() || mTabCount == 0) {
return;
}
final int height = getHeight();
// draw divider
if (mDividerWidth > 0) {
mDividerPaint.setStrokeWidth(mDividerWidth);
mDividerPaint.setColor(mDividerColor);
for (int i = 0; i < mTabCount - 1; i++) {
View tab = mTabsContainer.getChildAt(i);
canvas.drawLine(tab.getRight(), mDividerPadding, tab.getRight(), height - mDividerPadding, mDividerPaint);
}
}
// draw underline
if (mUnderlineHeight > 0) {
mRectPaint.setColor(mUnderlineColor);
canvas.drawRect(mPaddingLeft, height - mUnderlineHeight, mTabsContainer.getWidth() + mPaddingRight, height, mRectPaint);
}
// draw indicator line
if (mIndicatorHeight > 0) {
mRectPaint.setColor(mIndicatorColor);
Pair<Float, Float> lines = getIndicatorCoordinates();
if (lines != null) {
canvas.drawRect(lines.first + mPaddingLeft, height - mIndicatorHeight, lines.second + mPaddingLeft, height, mRectPaint);
}
}
}
代码示例来源:origin: lovejjfg/Circle
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode() || tabCount == 0) {
return;
}
final int height = getHeight();
// draw indicator line
rectPaint.setColor(indicatorColor);
// default: line below current tab
View currentTab = tabsContainer.getChildAt(currentPosition);
float lineLeft = currentTab.getLeft();
float lineRight = currentTab.getRight();
// if there is an offset, start interpolating left and right coordinates between current and next tab
if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
TextView nextTab = (TextView) tabsContainer.getChildAt(currentPosition + 1);
final float nextTabLeft = nextTab.getLeft();
final float nextTabRight = nextTab.getRight();
lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
}
if (textLengthVector == null) {
canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
} else {
float pointC = (lineRight + lineLeft) / 2 - textLengthVector[currentPosition] / 2;
float pointD = (lineRight + lineLeft) / 2 + textLengthVector[currentPosition] / 2;
canvas.drawRect(pointC, height - indicatorHeight, pointD, height, rectPaint);
}
}
代码示例来源:origin: wutq/AndroidModuleDemo
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: zx391324751/MoJiDemo
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int offset = computeHorizontalScrollOffset();
int maxOffset = computeHorizontalScrollRange() - DisplayUtil.getScreenWidth(getContext());
if(today24HourView != null){
// today24HourView.drawLeftTempText(canvas, offset);
today24HourView.setScrollOffset(offset, maxOffset);
}
}
代码示例来源:origin: Simon-Leeeeeeeee/SLWidget
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mIndicatorDrawable == null) {
return;
内容来源于网络,如有侵权,请联系作者删除!