Android-WebView在CardView中,Lollipop上没有圆角

3
为了展示一个带有圆角的webView,我将其放在了CardView中。结果如预期一样,出现了一个带有圆角的webView。
但是在lollipop上测试应用时,边角没有被圆形化,只显示了简单的webView。如何解决lollipop上的这个问题?
更新:以下是代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#222222"
android:clickable="true">

<androidx.cardview.widget.CardView
    android:id="@+id/card_holder"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:layout_marginLeft="25dp"
    android:layout_marginTop="50dp"
    android:layout_marginRight="25dp"
    android:layout_marginBottom="50dp"
    app:cardCornerRadius="30dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.cardview.widget.CardView
            android:id="@+id/top_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#FFFFFF"
            android:clickable="true"
            app:cardElevation="10dp">

            <RelativeLayout
                android:id="@+id/page_address"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_alignParentTop="true"
                android:layout_margin="10dp"
                android:background="@drawable/round_edge">

                <TextView
                    android:id="@+id/address_text_view"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_marginLeft="45dp"
                    android:layout_marginRight="45dp"
                    android:drawablePadding="2dp"
                    android:ellipsize="end"
                    android:lines="1"
                    android:textColor="#000000"
                    android:textSize="14dp" />

            </RelativeLayout>
        </androidx.cardview.widget.CardView>

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/top_bar"
            android:scrollbars="none" />
    </RelativeLayout>
</androidx.cardview.widget.CardView>


1
添加你目前还未运行成功的源代码。 - Shohan Ahmed Sijan
你的app.gradle文件中的目标SDK和最小SDK是什么? - Edgar
@sashabeliy 最小值:21 目标值:29 - Soheil
1个回答

0

在你的 app.gradle 文件中进行如下更改

compileSdkVersion 29
minSdkVersion 15
        targetSdkVersion 29

同步项目


我不理解这个答案的意义,我的应用程序中最小sdk版本是21,为什么要将其更改为15?! - Soheil
因为我在我的应用程序中使用Lollipop设备时,当min sdk版本为21时,遇到了圆角半径的相同问题,但是当我将其更改为15时,问题得到了解决。 - Edgar
我无法将minSdkVersion更改为15,因为其他库的原因。 - Soheil
发布你的Java代码后,你需要在Java代码中使用Lolipop注解,这将会有所帮助。 - Edgar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接