MaterialDatePicker缓慢 [英] MaterialDatePicker is slow
问题描述
我正在使用MaterialDatePicker,但是速度很慢.
I'm using MaterialDatePicker, but it's slow.
public class MainActivity extends AppCompatActivity
{
MaterialDatePicker.Builder<Long> datePickerBuilder;
MaterialDatePicker<Long> datePicker;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
datePickerBuilder = MaterialDatePicker.Builder.datePicker();
datePicker = datePickerBuilder.build();
Button btn = findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
datePicker.show(getSupportFragmentManager(), null);
}
});
}
}
首次按下该按钮时,需要3秒钟才能显示日期选择器.在随后的按钮单击中,它将在1秒钟内打开.在日期选择器中选择一个日期后出现延迟,这并不像您期望的那样平稳.
When the button is pressed for the first time it takes 3 seconds for the Date picker to show. On subsequent button clicks, it open in 1 second. After the selecting a date in date picker gives lag, it's not smooth as you would expect it to be.
对此有什么解决办法吗?
Is there any solution to this?
编辑:似乎还有更多错误.通过水平滚动更改月份和很多次都存在滞后,它将滑动2-3次并最终选择错误的月份.我认为MaterialDatePicker不可用,UX太糟糕了.
It seems there are more bugs. There is a lag when changing months by horizontal scrolling and a lot of times, it will slide 2-3 times and end up choosing the wrong month. I don't think MaterialDatePicker is usable, the UX is too bad.
推荐答案
请原谅,因为这应该是一条评论,但可惜我不能写一条,也许会对别人有所帮助.
I beg your pardon as this should be a comment, but alas I cannot write one, and maybe it can help somebody.
就像@TayyabMazhar一样,我还观察到Material Date Picker需要花费几秒钟来显示,并且通过水平滚动更改月份会产生视觉伪像.
As is happening to @TayyabMazhar, I have also observed that Material Date Picker takes a few seconds to show, and changing months by horizontal scrolling produces visual artifacts.
我在正在开发的应用程序以及Google的Material演示应用程序中都观察到了这一点(只是略有减少,因此-我可以确定选择器仍然很慢:但是,在logcat上看,两个应用程序都显示了很多帧)启动选择器时跳过,大约45).有趣的是,虽然我可以在手机上看到它(功能强大的SoC,6Gb RAM,安装的应用程序很少),但是当我运行例如功能不那么强大的仿真设备时,却看不到它.
I observe this both in an app I am developing, as well as in Googles Material demo app (only slightly less so - I can confirm the picker is still slow however: looking at the logcat both apps show quite a few frames being skipped when the picker is launched, ca 45). Funnily enough, while I can see this on my phone (powerful SoC, 6Gb RAM, very few apps installed), I cannot see it when I run, for example, a much less powerful emulated device.
此外,我尝试使用不同的材料版本1.3.0-alpha02、1.2.0、1.1.0 ...,但是得到了相同的结果.
Further, I have tried using different material versions, 1.3.0-alpha02, 1.2.0, 1.1.0... but got the same results.
这篇关于MaterialDatePicker缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!