0

在我的應用程序中,我使用網頁的網址在webview中顯示網頁。網址加載正常,但問題是網頁的一些內容是從底部裁剪。如何解決這個問題?任何幫助將不勝感激。 這裏是我的代碼Webview內容從底部裁剪[A​​NDROID]

XML代碼

<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代碼

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"); 

回答

0

嘗試這種滾動型使用

<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> 
+1

非常感謝它的工作.... :) – User

+0

最Welcomw @User –

0

嘗試給WebView一個layout_weight =「1」和0dp的高度。