我有一个应用程序,其左侧有 SlidingPaneLayout
(默认情况下隐藏),主布局位于屏幕的可见部分。显示 UI 元素,例如 TextView
、图标(使用 vectors
)和 SeekBar
在此主要布局中,并根据用户交互进行更新。布局是使用 ConstraintLayout
创建的。
<com....SlidingPaneLayout
layout_width="match_parent"
layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:id="@+id/left_panel"
layout_width="200dp"
layout_height="match_parent">
...
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/main_layout"
layout_width="match_parent"
layout_height="match_parent">
...
<ImageView
android:id="@+id/iv_example_icon"
app:srcCompat="@drawable/ic_icon" />
...
</android.support.constraint.ConstraintLayout>
</com....SlidingPaneLayout>
这种布局没有什么奇怪的。组件正在使用从主线程调用的 setText
、setImageResource
等方法进行更新。问题是,在某些设备上(最后一次出现在 Samsung J3,Android 5.1.1 上),这些方法不起作用(它适用于数以千计的其他设备)。单击元素,但内容未更新(例如,当用户触摸图标时更改图标)。它仅在 SlidingPane
显示(从左侧滑动)或 Activity 恢复后更新。有人知道什么可以阻止应用程序更新这些元素吗?它在新更新之前运行良好。带来的新更新:ConstraintLayout
、png 背景、vector
图标。
谢谢。
最佳答案
发现问题。将淡入淡出颜色从半透明设置为透明解决了这个问题。
this.setSliderFadeColor(ContextCompat.getColor(context, android.R.color.transparent));
但是我仍然不知道这是为什么。
关于android - 某些设备上的 UI 未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52327208/