I need to add a shadow to a Button with these attributes "from zelplin":
and this is the design
I tried this code
<Button
android:id="@+id/btn_sign_in"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="35dp"
android:background="@drawable/auth_button_shape"
android:shadowColor="#41ff4800"
android:shadowDx="0"
android:shadowDy="8"
android:text="@string/sign_in"
android:textAllCaps="true"
android:textColor="@android:color/white"
android:textSize="14sp" />
auth_button_shape
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ff7c44" />
<corners android:radius="100dp" />
</shape>
But not worked and the other attributes "Blur" and "Spread" How I can set them for the button.
Thanks.
use
AppCompatButton
instead ofButton
,useelevation
and useandroid:backgroundTint
for button colour.output is,
bg_test.xml
:Activity.xml
code:Design Button :
Thanks to Taras I have solution. You can use this library for creating colored shadow to button. Just place your view element inside shadow layout. Of course basic layout is ConstraintLayout. Some pieces of code for example
Button shape :
Result: