[当尝试将静态片段与layout_height="wrap_content"
一起使用时,UI并未按预期出现。
<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);
在设备中出现类似这样的内容
任何解决方案如何解决此问题?
在片段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">