我和朋友一起创建了一个 Android 应用程序,但我遇到了一个与 UI 相关的奇怪问题。
在片段之间切换时,有时 UI 会出现混乱,请在下方创建一个故障。
它发生在我的带有 Dalvik 运行时和股票 Android 的 Nexus 5 上,以及我朋友的带有 ART 运行时和 SlimKat rom 的 Nexus 4 上。但在另一个带有 Dalvik 运行时和 4.4.2 (AOSB rom) 的 Nexus 5 上无法观察到。奇怪的是,在我更新到最新版本的应用程序之前,它并没有发生。
下面是使用的布局,这里是我使用事务main_fragment
放置的地方。Fragment
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/main_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</RelativeLayout>
我发现执行此行时会出现故障,而我在方法中放入的内容无关紧要setBackgroundDrawable
:
activity.getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(getCurrentTheme(activity))));
还有人有这个问题吗?或者也许有人知道一种解决方法或如何使其工作?
编辑:我需要在运行时更改 ActionBar 颜色(在应用程序设置中更改主题)。