我正在使用 android 支持包 v4 和以下布局来显示可滚动的标签栏 + 相应的可滑动内容视图:
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:gravity="center_vertical"
android:layout_height="wrap_content">
<HorizontalScrollView
android:layout_width="wrap_content"
android:id="@+id/horizontalScrollView"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none">
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</HorizontalScrollView>
</LinearLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</TabHost>
它运作良好可以说 90% 但 10% 它只是不重绘 ui。即使元素无效也不能解决问题。现在最奇怪的部分:在锁定和重新锁定手机后,一切都按预期显示,并且像魅力一样工作。
例如:我添加了一个新的选项卡 + 片段。- 添加了 Tab + Fragment,调用了它们上的所有方法,但 UI 只是黑色。锁定+解锁 = 一切都好起来了。
处理片段上的用户输入。(见图)
注意:我已经测试了所有元素的失效,它不起作用。
我还能做些什么来解决这个问题?
提前致谢