I'm trying to make this button.

enter image description here

I try to do it in a similar way, something like:

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item > <shape android:shape="rectangle" > <gradient android:startColor="#ff297baf" android:endColor="#ff16c0e3" android:type="linear" android:angle="0" /> </shape> </item> <item android:top="3dp" android:right="3dp" android:left="3dp" android:bottom="3dp" > <shape android:shape="rectangle" > <solid android:color="#FFFFFFFF" /> </shape> </item> </layer-list> 

those. I'm trying to make one shape a gradient and inside it another piece is just white with indents, but I see either one gradient or only white, I tried to indent both there and there. What could be the problem? How to make nested shapes?

    1 answer 1

    In general, my problem is not reproduced.

    here is the markup:

     <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape> <corners android:radius="4dp"> </corners> <gradient android:startColor="#634b25" android:endColor="#96743e" android:centerColor="#e4dbce" /> </shape> </item> <item android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp"> <shape> <corners android:radius="4dp"> </corners> <solid android:color="#fff" /> </shape> </item> </layer-list> 

    here is the result:

    scrn

    I just removed the attributes that duplicate the default and everything basically. Another gradient from the center.

    • Well, I tried to do this in the same way, but without starting the project, it’s seen in a preview in a slightly different way! - Kirill Stoianov
    • one
      @KirillStoianov After making changes to the markup, you need to do a Make (or even Rebuild sometimes) project, so that the changes are correctly displayed in the studio preview, otherwise there is some kind of chaos quickly formed. - pavlofff