【问题标题】:Android : show webview in a circled shapeAndroid:以圆形显示webview
【发布时间】:2015-12-02 11:32:04
【问题描述】:
我有一个 android webview 如下:
<WebView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/userImage"
android:background="@drawable/circle"/>
我必须以圆形显示这个 webview。我是安卓新手。谷歌搜索并尝试了许多代码。但它不起作用。任何人都可以给我可绘制的代码,以像在whattsapp用户图像中一样以圆形显示webview。
【问题讨论】:
标签:
android
android-layout
webview
android-webview
android-drawable
【解决方案1】:
这是网页视图布局
<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>
rounded.xml
<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>
此代码适用于我检查此link
【解决方案2】:
创建新的 xml circle.xml 并粘贴此代码
。
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by FirozShaikh on 02/12/2015. -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:height="100dp"
android:width="100dp" />
<solid android:color="@color/blue"/>
</shape>