Android - WebView 的问题

标签 android webview shapes

我正在努力解决这个问题并多次解析网络以理解以下内容。

我正在使用嵌入 WebView 的简单 Activity:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/tables"
</LinearLayout>

如您所见,我正在尝试应用可绘制形状 (android:background="@drawable/tables"),以便 WebView 具有圆角、描边边框...... .

问题是 WebView 没有得到任何我试图设置的外观(没有圆角等...)。

我要应用的形状代码:

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <solid   android:color="@color/fond_tables"/>
     <corners android:bottomRightRadius="10dp"
              android:bottomLeftRadius="10dp" 
              android:topLeftRadius="10dp"
              android:topRightRadius="10dp"/> 
     <stroke  android:width="3dp"
              android:color="@color/bordure_tables" />
</shape>

如果有人能帮我解决这个问题,我将不胜感激。

提前致谢

亚当。

最佳答案

我也遇到了同样的问题。后来我知道我们不能改变 webView 的背景。您可以更改布局背景。我已经尝试过这种方法,效果很好。

<TableRow
    android:id="@+id/tableRow5"

    android:background="@drawable/fullshape"

    android:layout_width="300dp"
    android:layout_height="300dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="10dp" >

    <WebView
        android:id="@+id/webView1"
        android:layout_width="280dp"
        android:layout_height="280dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp" />

</TableRow>

关于Android - WebView 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5246425/

相关文章:

python - 在 Python 中,如何缩放存储为 NumPy 数组的图像的大小?

android - 无法在 Android 设备上获取准确位置

c# - WebView cookie Windows 8

java - 在 webview 上设置 Imagebutton

Java2D : Fill a convex rounded polygon (QuadCurves)

r - 是否可以在组合线图和点图上更改颜色和形状,同时保留每个图表一个图例?

android - 使用 sw-600dp 布局的最小屏幕尺寸是多少?

android - 如何向 ImageSwitcher Timer 添加更多图片?

java - 从 Google App Engine 调用 Firebase 数据库

android - 出现键盘时 Webview 不调整大小