<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <item> <shape android:shape="rectangle"> <solid android:color="#AAEEEEEE"/> <corners android:radius="2dp" /> </shape> </item> <item android:bottom="1dp"> <shape android:shape="rectangle"> <solid android:color="#AACCCCCC"/> <corners android:radius="2dp" /> </shape> </item> <item android:left="1dp" android:right="1dp" android:top="0dp" android:bottom="2dp"> <shape android:shape="rectangle"> <solid android:color="@android:color/white"/> <corners android:radius="2dp" /> </shape> </item> </layer-list> 

In this style, the elements in the ListView are decorated and look like this enter image description here

I'm trying to add a second rectangle to draw like this. enter image description here

But it does not work to do it correctly. The second option is obtained by adding at the end of the layer-list

 <item android:left="1dp" android:right="1dp" android:top="0dp" android:bottom="2dp" android:width="60dp"> <shape android:shape="rectangle"> <solid android:color="#AACCCCCC"/> </shape> </item> 

But it works correctly only in the preview. Tell me how to edit to display correctly?

    1 answer 1

    Most likely you run on the device <API 23, because parameter android:width for item supported since API 23

    Maybe it will be easier for you to set the background right away from TextView , which is responsible for displaying the PDF

    And another question, why do you manually create a shadow for the card, and not use Google CardView

    • When I wrote the code 2 years ago, I did not know about the existence of cards, but now I don’t want to refactor a lot of code because of this. - T2skler