I try to add elevation to my TextInputLayout but android:elevation="10dp doesn't work! How can I do this?
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:elevation="10dp>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
/>
</com.google.android.material.textfield.TextInputLayout>
Views won't cast a shadow unless they have a non-null background set, andTextInputLayoutdoesn't have one. It manages the background on the nestedEditTextinstead. You could simply set your own background on it, but that might taking some fiddling to get it to line up correctly with the other decorations. Also, it's not clear how you want this to look, exactly, but I should mention that the shadow will not be affected byTextInputLayout's cutout, and the floating hint has no background of its own, so you might end up with some ugly artifacts in certain styles/themes.android:outlineProvider="bounds"on the<TextInputLayout>. That'll cause the shadow to be strictly rectangular, but with a small corner radius it's not really noticeable: i.sstatic.net/lqizJ.png.