【问题标题】:Need Help in Displaying Image correctly in WebView in Android?需要帮助在 Android 的 WebView 中正确显示图像?
【发布时间】:2010-11-10 08:57:16
【问题描述】:

海友们, 我已经从 url 解析了图像,并显示在 webview 中,当我在 webview 中显示它时,一些图像被拉伸,所以我在 Imageview 的帮助下显示了图像,但问题是图像没有显示在Imageview 当它们的颜色格式是 CMYK 格式时,请告诉我如何在没有图像拉伸的情况下在 webview 中显示图像,或者如何在 ImageView 中显示所有格式的图像。

我的xml代码是

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout02_img"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">             
         <WebView android:id="@+id/ads_content" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">
</WebView>
</LinearLayout>

我的java代码是

私有 WebView ads_content; ads_content = (网络视图) findViewById(R.id.ads_content); ads_content.loadUrl(url);

请参阅显示我的输出的屏幕截图

我必须将图像显示到设备级别,泰语是为了阻止白色和黑色的空白区域 谢谢

【问题讨论】:

  • 张贴一些截图也许我们可以提供帮助。

标签: android


【解决方案1】:

海友们, 最后我得到了这个问题的解决方案,参考我的xml代码

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout02_img"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_gravity="center"
    android:layout_alignParentBottom="true"
    android:background="@color/black"
                android:layout_alignParentLeft="true">               

    <WebView android:id="@+id/ads_content" 
    android:layout_gravity="center"
    android:scaleType="centerInside"
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent"

    android:adjustViewBounds="true">
</WebView>
</LinearLayout>

【讨论】:

    【解决方案2】:

    您可以尝试将 WebView 布局设置为单列。它会自动将所有图像调整为屏幕宽度。

    webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

    来自我的回答here

    【讨论】:

      猜你喜欢
      • 2015-08-06
      • 2011-05-13
      • 1970-01-01
      • 2011-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-05
      • 2021-08-08
      相关资源
      最近更新 更多