WebView не отображается внутри TabHost на Honeycomb при первом открытии вкладки

В моем приложении есть следующий вид:

<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) - когда я впервые открываю вкладку описания - веб-просмотр не отображается. После возврата на предыдущую вкладку и повторного открытия - веб-просмотр отображается правильно.


person Pavel Samokha    schedule 27.08.2011    source источник


Ответы (1)


Хотя я все еще думаю, что это ошибка Honeycomb (но нашел нечто подобное здесь http://code.google.com/p/android/issues/detail?id=15399 для 2.2), я нашел обходной путь:

Использование android:layout_height="wrap_content" для веб-просмотра вместо fill_parent по-прежнему дает мне то, что я хочу, и сразу показывает.

person Pavel Samokha    schedule 28.08.2011