【问题标题】:web view doesn't show all data网络视图不显示所有数据
【发布时间】:2023-01-03 00:12:23
【问题描述】:

我用 api 获取页面的内容。 但它不显示所有内容。

Log.e("content",newsDetailModel.getFullContent()); //it shows all data
WebSettings settings = news_details_content.getSettings();
settings.setJavaScriptEnabled(true);
settings.setAllowContentAccess(true);
settings.setDomStorageEnabled(true);
news_details_content.setWebChromeClient(new WebChromeClient());
           
String content = newsDetailModel.getFullContent();
news_details_content.loadData(content, "text/html", "utf8");

我的看法:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/background">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="10dp">


        <ImageView
            android:id="@+id/news_details_image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitXY"/>
  

        <WebView
            android:id="@+id/news_details_content"
            android:layout_width="match_parent"
            android:layout_gravity="right"
            android:layout_height="wrap_content"/>

</LinearLayout>



</RelativeLayout>

【问题讨论】:

  • ca 请在此处添加您的完整布局文件?
  • @达瓦拉。添加了完整的布局。

标签: java android webview


【解决方案1】:

得到你的问题。

这是因为您为 ImageView 使用了 wrap_content 高度。 这意味着如果您的图像具有高分辨率,它将几乎占据屏幕上的所有内容。并将在屏幕外绘制您的网络视图。

所以我建议你将 ImageView 的高度固定。 用以下代码替换您的布局文件代码。它会解决你的问题。您可以调整 ImageView 的高度。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/background">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="10dp">

        <ImageView
            android:id="@+id/news_details_image"
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:scaleType="fitXY" />


        <WebView
            android:id="@+id/news_details_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="right" />

    </LinearLayout>

</RelativeLayout>

【讨论】:

    猜你喜欢
    • 2013-12-06
    • 1970-01-01
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    • 2013-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多