【问题标题】:Android-webview inside cardview, no rounded corners on lollipopCardview里面的Android-webview,棒棒糖上没有圆角
【发布时间】:2020-06-10 01:09:08
【问题描述】:

为了显示一个带圆角的 webview,我将它放在 CardView 中,结果如预期的那样,一个带圆角的 webview。

但是在lollipop 上测试应用程序时,边角不是圆角的,只显示了一个简单的 web 视图。如何在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>

【问题讨论】:

  • 添加您当前尚未工作的源代码。
  • 你在 app.gradle 中的目标 sdk 和 minsdk 是什么
  • @sashabeliy min:21 目标:29

标签: android webview material-design android-cardview


【解决方案1】:

在你的 app.gradle 中像这样改变

compileSdkVersion 29
minSdkVersion 15
        targetSdkVersion 29

并同步项目

【讨论】:

  • 我不明白这个答案的意义何在,我的应用中的min sdk版本是21,我为什么要把它改成15?!
  • 因为我在使用棒棒糖设备的应用程序中使用 min sdk 版本 21 时遇到了与圆角半径相同的问题,在更改为 15 后它解决了我的问题
  • 由于其他库,我无法将 minSdkVersion 更改为 15
  • 发布您的 java 代码,然后您必须在 java 代码中使用 lolipop 注释,我认为这会有所帮助
猜你喜欢
  • 2015-08-12
  • 2015-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-12
  • 2016-02-28
  • 2016-02-11
  • 1970-01-01
相关资源
最近更新 更多