I created a CustomTextInputLayout class and set the style to Resource.Style.Widget_MaterialComponents_TextInputLayout_OutlinedBox and BoxBackgroundMode to BoxBackgroundOutline but the OutlinedBox is still not showing. I'm using Xamarin.Android.
public class CustomTextInputLayout : TextInputLayout
{
public CustomTextInputLayout(Context context) : base(context, null, Resource.Style.Widget_MaterialComponents_TextInputLayout_OutlinedBox)
{
Init(context);
}
public CustomTextInputLayout(Context context, IAttributeSet attrs) : base(context, attrs, Resource.Style.Widget_MaterialComponents_TextInputLayout_OutlinedBox)
{
Init(context);
}
public CustomTextInputLayout(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
{
Init(context);
}
public void Init(Context context)
{
var textInputEditText = new TextInputEditText(context) { LayoutParameters = new LayoutParams(-1, -2) };
AddView(textInputEditText);
BoxBackgroundMode = BoxBackgroundOutline;
}
}
This is the content_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main">
<MaterialTest.CustomTextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
And this is the AppTheme
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
This is what it looks like (no OutlinedBox):
Any help would be appreciated.