Webview 内容从底部被裁剪 [ANDROID]
Webview contents getting cropped from bottom [ANDROID]
在我的应用程序中,我使用网页的 url 在 webview 中显示网页。 url 加载正常,但问题是网页的某些内容从底部被裁剪。如何解决这个问题?任何帮助将不胜感激。
这是我的代码
xml code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/app_bg_color"
>
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
layout="@layout/empty_result_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Java code
String Content = "<h2>" + ItemDetail.getTitle() + "</h2>\n" + ItemDetail.getWebviewContent();
Content = Content.replaceAll("a href=\"/", "a href=\"" + ConstantFile.SERVER_ADDRESS + "/");
webview.loadDataWithBaseURL(null, Content, "text/html", "UTF-8", null);
webview.getSettings().setDefaultTextEncodingName("UTF-8");
尝试使用滚动视图
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/app_bg_color" >
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
layout="@layout/empty_result_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</ScrollView>
尝试给 WebView
一个 layout_weight="1"
和 height
的 0dp
。
在我的应用程序中,我使用网页的 url 在 webview 中显示网页。 url 加载正常,但问题是网页的某些内容从底部被裁剪。如何解决这个问题?任何帮助将不胜感激。 这是我的代码
xml code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/app_bg_color"
>
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
layout="@layout/empty_result_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Java code
String Content = "<h2>" + ItemDetail.getTitle() + "</h2>\n" + ItemDetail.getWebviewContent();
Content = Content.replaceAll("a href=\"/", "a href=\"" + ConstantFile.SERVER_ADDRESS + "/");
webview.loadDataWithBaseURL(null, Content, "text/html", "UTF-8", null);
webview.getSettings().setDefaultTextEncodingName("UTF-8");
尝试使用滚动视图
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/app_bg_color" >
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
layout="@layout/empty_result_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</ScrollView>
尝试给 WebView
一个 layout_weight="1"
和 height
的 0dp
。