【问题标题】:WebView not shown inside TabHost on Honeycomb when open tab first time第一次打开选项卡时,WebView 未显示在 Honeycomb 上的 TabHost 内
【发布时间】:2011-08-27 11:09:33
【问题描述】:

在我的应用中有以下视图:

<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"
    android:paddingTop="0dip">
    <TabWidget android:id="@android:id/tabs"
        android:layout_width="fill_parent" android:layout_height="wrap_content" />
    <FrameLayout android:id="@android:id/tabcontent"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:padding="5dp">
        <ScrollView android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            ....first tab content....
        </ScrollView>
        <WebView android:id="@+id/description" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:layout_weight="1">
        </WebView>
    </FrameLayout>
</LinearLayout>
</TabHost>

活动中:

TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab_details").setIndicator("Details",getResources().getDrawable(R.drawable.ic_tab_details)).setContent(R.id.details));
tabHost.addTab(tabHost.newTabSpec("tab_description").setIndicator("Description",getResources().getDrawable(R.drawable.ic_tab_description)).setContent(R.id.description));
tabHost.setCurrentTab(0);

WebView descriptionView = (WebView)findViewById(R.id.description);

String formattedDescription = converter.toHtmlPage(description);
descriptionView.loadData(formattedDescription, "text/html", "utf-8");

Android 1.6-2.3 一切正常,但在 Honeycomb 上(在 Android 3.1 模拟器上测试) - 当我第一次打开描述选项卡时 - 未显示 webview。返回上一个选项卡并再次打开后 - webview 正确显示。

【问题讨论】:

    标签: android webview android-3.0-honeycomb android-tabhost


    【解决方案1】:

    虽然我仍然认为这是 Honeycomb 错误(但在 http://code.google.com/p/android/issues/detail?id=15399 找到了类似 2.2 的内容),但我找到了解决方法:

    为 webview 使用 android:layout_height="wrap_content" 而不是 fill_parent 仍然给我想要的东西并立即显示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多