In app there are is an option to change the theme color and depending on theme color I am changing the color of toolbar background using following line:
toolbar.setBackgroundColor(getResources().getColor(R.color.white));
However, I could not find anything which can help me to change the color of Elevation. Here is the toolbar xml:
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/headset"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/contact_us"
android:textColor="@color/gray"
android:textSize="18sp" />
</RelativeLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
Please let me know how can I do it programmatically.