The*_*hod 31 android android-cardview
我正在使用cardview作为我正在编写的自定义视图的根.我使用的是v7支持库.我的XML看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="6dp"
card_view:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- some other views -->
</LinearLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
我的问题是我的卡片视图周围有一个白色边框.它看起来像是指示高度,因为它在右侧较厚.我试过调整,cardElevation并MaxCardElevation在我的XML中这样:
card_view:cardElevation="0dp"
并在我的自定义视图中的代码中扩展CardView并使用此布局:
setCardElevation(0);
setMaxCardElevation(0);
Run Code Online (Sandbox Code Playgroud)
但白色边界仍然存在.我不知道如何摆脱它.如果有人对此为何发生任何意见或建议如何删除白色边框,我们将不胜感激.非常感谢.
小智 84
我知道这有点晚了,但对于有类似问题的人:
我遇到了同样的问题:在棒棒糖前设备上显示了白色边框.
我解决了它的设置cardPreventCornerOverlap到false你的XML.
像这样:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="6dp"
card_view:cardPreventCornerOverlap="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- some other views -->
</LinearLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!
| 归档时间: |
|
| 查看次数: |
33748 次 |
| 最近记录: |