Remote ListView blinks on android widget

2019-02-28 21:42发布

问题:

I am having an unexpected bothering issue with a remote listview. My app has a simple widget which includes a listview. If the listview has 1 cell height and the listview is at the beginning of its scroll it blinks/flahses everytime datasetchanged is called. The funny thing is that if the listview has more than 1 cell height or if it has 1 cell height BUT it has been scrolled down a bit it doesnt blink. Could anybody please provide some suggestion? I am frustrated. Solutions I have thought so far: 1. Disable loading view (which is what is causing the flash) on the remoteViewFactory. However I dont know how to do this. Dont even know if it would work.

Thank you very much.

回答1:

Ok I found a solution to blinking problem while clicking the widget. For example if you look at youtube app in android, you might recognize it waits you until its open. In below, you may try to set android:windowDisablePreview to true in your style.xml. I believe Google used same method to prevent preview mode in Youtube app.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/Widget.AppCompat.ActionBar</item>
        <!-- closed the preview window -->
        <item name="android:windowDisablePreview">true</item>

    </style>

I hope this solution helps you.