We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如题, 经过查看我发现这个问题的确是有的 在BackgroundCountdown#initStyleAttr(Context context, TypedArray ta)方法中第 51行和54行有这样的代码
mTimeBgBorderSize = ta.getDimension(R.styleable.CountdownView_timeBgBorderSize, Utils.dp2px(context, DEFAULT_TIME_BG_BORDER_SIZE)); isShowTimeBgBorder = ta.getBoolean(R.styleable.CountdownView_isShowTimeBgBorder, false);
但是 DEFAULT_TIME_BG_BORDER_SIZE 默认为 1dp 在 onDraw(Canvas canvas) 方法中各个Suffix的处理中,有:
if (mSuffixDayTextWidth > 0) { // draw day suffix canvas.drawText(mSuffixDay, mLeftPaddingSize + mDayTimeBgWidth + mSuffixDayLeftMargin + (mTimeBgBorderSize * 2), mSuffixDayTextBaseline, mSuffixTextPaint); }
这个 mTimeBgBorderSize * 2 造成了 mSuffixDay 右移的情况, 因为此时并不显示TimeBgBorder,但是却计算了 mTimeBgBorderSize 的值,因此建议在 initStyleAttr(Context context, TypedArray ta) 方法中54行的:
isShowTimeBgBorder = ta.getBoolean(R.styleable.CountdownView_isShowTimeBgBorder, false);
下面添加:
if (!isShowTimeBgBorder) { mTimeBgBorderSize = 0; }
来处理,即当不显示背景边框的时候,这个边框的大小为0,不接入计算.
ps: demo中的DynamicShowActivity显示没有问题是因为其在第471行左右对border进行了设置:
((CheckBox) findViewById(R.id.cb_bgBorder)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { btnModBgBorderColor.setEnabled(isChecked); btnBgBorderSizePlus.setEnabled(isChecked); btnBgBorderSizeSubtract.setEnabled(isChecked); btnBgBorderRadiusPlus.setEnabled(isChecked); btnBgBorderRadiusSubtract.setEnabled(isChecked); DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder(); dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(isChecked)); mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build()); } }); ((CheckBox) findViewById(R.id.cb_bgBorder)).setChecked(false);
The text was updated successfully, but these errors were encountered:
app:isShowTimeBgBorder="true" app:timeBgBorderColor="@color/transparent" 如果不想显示边框,文字并且居中,可以设置边框颜色为透明即可
Sorry, something went wrong.
app:isShowTimeBgBorder="true" app:timeBgBorderColor="@color/transparent" 如果不想显示边框,文字并且居中,可以设置边框颜色为透明即可 麻烦看下这个问题呢? #132
No branches or pull requests
如题, 经过查看我发现这个问题的确是有的
在BackgroundCountdown#initStyleAttr(Context context, TypedArray ta)方法中第 51行和54行有这样的代码
但是 DEFAULT_TIME_BG_BORDER_SIZE 默认为 1dp
在 onDraw(Canvas canvas) 方法中各个Suffix的处理中,有:
这个 mTimeBgBorderSize * 2 造成了 mSuffixDay 右移的情况, 因为此时并不显示TimeBgBorder,但是却计算了 mTimeBgBorderSize 的值,因此建议在 initStyleAttr(Context context, TypedArray ta) 方法中54行的:
下面添加:
来处理,即当不显示背景边框的时候,这个边框的大小为0,不接入计算.
ps: demo中的DynamicShowActivity显示没有问题是因为其在第471行左右对border进行了设置:
The text was updated successfully, but these errors were encountered: