Android stati c фрагмент: когда высота макета равна wrap_content, текст не отображается должным образом - PullRequest
0 голосов
/ 02 апреля 2020

При попытке использовать фрагмент c stati с layout_height="wrap_content" пользовательский интерфейс не отображается должным образом.

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    <fragment
                android:id="@+id/fragment1”
                android:name=“…..”
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/fragment2" />
    <fragment
                android:id="@+id/fragment2”
                android:name=“….”
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true" />
</RelativeLayout>

Fragment2 имеет такой макет

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:weightSum="1">
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.7">
        <WebView
            android:id="@+id/webview”
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:orientation="vertical">
        <Button
            android:id="@+id/btn1”
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <Button
            android:id="@+id/btn”2
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</LinearLayout>

При попытке перезагрузить содержимое в WebView с текстом

web.loadData("I confirmed that I have read and understand all the materialfasd<br>fasd<br>fase<br>....fasd", "text/html; charset=utf-8", null);

Это выглядит примерно так в устройстве

enter image description here

Есть решение, как решить эту проблему?

1 Ответ

0 голосов
/ 02 апреля 2020

во фрагменте 2

Заменить

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:weightSum="1">

на

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="1">
...