Skip to content
New issue

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

文字测量问题 #64

Open
handy315 opened this issue Jul 13, 2017 · 8 comments
Open

文字测量问题 #64

handy315 opened this issue Jul 13, 2017 · 8 comments

Comments

@handy315
Copy link

将天数转换成小时,小时为3位数时,显示时分秒的倒计时,小时数会紧贴后面的冒号,效果如下:
111: 23 : 00

@zhuzhushang
Copy link

我也遇到这样的问题。请问有解决方法吗?

@iwgang
Copy link
Owner

iwgang commented Nov 8, 2017

给下布局和代码

@Selina592732122
Copy link

Selina592732122 commented Nov 8, 2017

listview滑动的时候,天数超过两位的,文字会被挤没了,请问有解决方法吗
image
image

@zhuzhushang
Copy link

看一下图

代码 constraintlayout---->Linearlayout--->CountdownView
<cn.iwgang.countdownview.CountdownView
android:id="@+id/countdownView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
app:isConvertDaysToHours="true"
app:isShowDay="false"
app:isShowHour="true"
app:isShowMillisecond="true"
app:isShowMinute="true"
app:isShowSecond="true"
app:isTimeTextBold="true"
app:timeTextColor="@color/count_down_text_color"
app:timeTextSize="28sp" />

java 代码直接start

可能主要是因为有app:isConvertDaysToHours="true"
我测试了一下,
第一次进入,小时超过3位就会显示异常。
按home键回到主界面,在点击icon进入异常。
按back键返回,点击icon显示正常,按功能键去掉任务栈,点击icon进入异常。
点击功能键,然后再点击功能键进入界面就正常了。

@Selina592732122
Copy link

Selina592732122 commented Nov 8, 2017

public boolean handlerDayLargeNinetyNine() {
	boolean isReLayout = false;
	if (isShowDay) {
		// handler large ninety nine
		if (isDayLargeNinetyNine) {
			isReLayout = true;
		}
		else if (!isDayLargeNinetyNine && mDay > 99) {
			isDayLargeNinetyNine = true;
			isReLayout = true;
		}
		else if (isDayLargeNinetyNine && mDay <= 99) {
			isDayLargeNinetyNine = false;
			isReLayout = true;
		}
	}
	return isReLayout;
}

需要加上下面这个逻辑判断,就可以了,因为有可能第一次isDayLargeNinetyNine被置为true,第二次就跑不进(!isDayLargeNinetyNine && mDay > 99)这个if里面了
if (isDayLargeNinetyNine) {
isReLayout = true;
}

@zhuzhushang
Copy link

@Selina592732122 这样会不会开销很大? 毕竟只需要relayout一次就好了,这样次次都relayout.

@Selina592732122
Copy link

@zhuzhushang 不用加relayout了,看了下他原来代码就有,只是条件进不去,
image

修改下貌似就可以了
public boolean handlerDayLargeNinetyNine() {
boolean isReLayout = false;
if (isShowDay) {
// handler large ninety nine
if (isDayLargeNinetyNine) {
isReLayout = true;
}
else if (!isDayLargeNinetyNine && mDay > 99) {
isDayLargeNinetyNine = true;
isReLayout = true;
}
else if (isDayLargeNinetyNine && mDay <= 99) {
isDayLargeNinetyNine = false;
isReLayout = true;
}
}
return isReLayout;
}

@sunwen0402
Copy link

大佬们最终怎么解决的?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants