I do CardView. I want the card to be completely empty, but for some reason I can not remove the stroke around it.

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="3dp"> <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_chat_message_view" android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="100dp" card_view:cardBackgroundColor="#00000000" card_view:cardElevation="0dp"> </android.support.v7.widget.CardView> </LinearLayout> 

The figure clearly shows this stroke.

enter image description here

  • Markup - an element for ListView? .. - Yuriy SPb
  • No, this is RecycleView. - strevg
  • <RelativeLayout xmlns: android = " schemas.android.com/apk/res/android " android: orientation = "horizontal" android: layout_width = "match_parent" android: layout_height = "match_parent"> <LinearLayout android: layout_width = "match_parent" android: layout_height = "match_parent"> <android.support.v7.widget.RecyclerView android: layout_width = "match_parent" android: layout_height = "match_parent" android: id = "+ + id / chat_rv" android: background = "# c2fbba "/> </ LinearLayout> </ RelativeLayout> - strevg
  • This is where I put everything - strevg
  • No need for markup in the comments - better in question. And why are there so many unnecessary elements? .. And do you have AppCompatActivity? And in the styles attribute background and windowBackgound not redefined? - JuriySPb

3 answers 3

This display is caused by the background transparency for CardView . It is treated by removing the transparency.

To make it transparent and without flat lines will not work out by standard means. We'll have to replace the card with a regular view with a hand-drawn frame as the background.

  • This is true. The only question is not how to remove the green color. And how to remove the gray stroke near CardView. I tried to disable CardView, make it invisible, then the stroke disappears. Therefore, it's CardView, not the parent who stores it. - strevg
  • @strevg, try adding the card_view:useCompatPadding="true" attribute card_view:useCompatPadding="true" to the layout of the card and / or playing with the alpha channel of the background of the card - Yuriy SPb
  • Those. Try color without transparency. of type @android:color/green - Yuriyi SPb
  • And it is not clear why the card is also stuck in Linear - YuriySPb
  • Put the color of the card, the same as the background, without alpha channel. The stroke is gone. This solution will help when the background under the cards is uniform, and what to do when there is a picture in the background? - strevg

Remove the stroke on CardView failed. I found another way: you have to not use CardView, but use another container (for example, LinearLayout) and insert it into the RecycleView.

    The stroke of the CardView widget is ideological for this widget. That it distinguishes it from other types of widgets. But at the same time it fits well with the ideas of material design. If you try to remove the stroke, then part of the idea embedded in it is lost. If you need an implementation without a stroke, it is easier to use a ListView customizable for yourself.

    • ListView does not suit me, only because compared to RecycleView, it will have to implement a lot of methods and customize it under Material Design. - strevg
    • but you and CardView are not suitable .. In this case, try using RecycleView as a container and using a custom view as an element - ZigZag
    • I decided to do it)) I suggested this answer in the morning) - strevg
    • Well, that came to a single option)) - ZigZag