MaterialDatePicker is slow

為{幸葍}努か 提交于 2021-02-10 14:40:33

问题


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);
            }
        });
    }
}

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?

EDIT: 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.


回答1:


I beg your pardon as this should be a comment, but alas I cannot write one, and maybe it can help somebody.

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.

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.

Further, I have tried using different material versions, 1.3.0-alpha02, 1.2.0, 1.1.0... but got the same results.



来源:https://stackoverflow.com/questions/62704481/materialdatepicker-is-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!