安卓:给的WebView圆角? [英] Android: give a webview rounded corners?

查看:2508
本文介绍了安卓:给的WebView圆角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想给我的web视图圆角。

I'm trying to give my webView rounded corners.

下面是我的code:

rounded_webview.xml:

rounded_webview.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
 <solid android:color="#000"/>
    <corners
     android:bottomRightRadius="15dp"
     android:bottomLeftRadius="15dp"
  android:topLeftRadius="15dp"
  android:topRightRadius="15dp"/>
</shape>

和这里是我的web视图:

And here is my webView:

<WebView
        android:id="@+id/webView1"
        android:layout_width="293dp"
        android:layout_height="142dp"
        android:layout_gravity="center_horizontal"
        android:padding="5dip"
        android:background="@drawable/rounded_webview"/>

但它是行不通的!角不圆...

But it simply won't work! Corners are not rounded...

在预先感谢,

推荐答案

的唯一办法是换行的WebView元素被其他视图(的FrameLayout为例),并应用圆角背景的外观图。 例如:

The only way is wrap WebView element by other view (FrameLayout for example), and apply rounded corners background on external view. Example:

<FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="10dip"
        android:paddingBottom="10dip"
        android:paddingLeft="1dip"
        android:paddingRight="1dip"
        android:background="@drawable/white_rounded_area"
        >
    <WebView
            android:id="@+id/web_view"
            android:layout_width="300dip"
            android:layout_height="400dip"
            android:layout_gravity="center"
            />
</FrameLayout>

其中的 paddingTop paddingBottom会等于半径从绘制/ white_rounded_area 以下属性来 paddingRight 等于笔划宽度绘制/ white_rounded_area

Where paddingTop and paddingBottom equals radius from drawable/white_rounded_area, paddingLeft and paddingRight equals stroke width drawable/white_rounded_area.

这种方法的负是顶部的圆形底部的面板可以有不同的背景颜色与内部的WebView网页,尤其是当页面滚动。

Minus of this approach is top an bottom rounded panels can have different background color with web page inside WebView, especially when page scrolled.

这篇关于安卓:给的WebView圆角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆