Material design TextInputLayot, как сделать обводку(рамку) вокруг поля?
В Материал дизайне есть описания отображение EditText Ссылка на описание.
Есть два типа отображеня Filled и Outline(на моем рисунке 1 и 2 соответсвенно)

Кто нибудь знает как в режиме Filled сделать обводку не снизу, а полную, что-то типа рамки, как на рисунке 2. Я пробовал решение как тут:ccылка на найденное решение, но оне не сработало.
Подскажите пожалуйста какие есть варианты решения? Что получилось вот так:

Ответы (2 шт):
Добавить в xml поле для ввода:
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat 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"
tools:context=".MainActivity">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/outlined_text_input_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:placeholderText="Placeholder Text"
android:hint="OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/outlined_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
то что вам нужно находится здесь:
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
итог:
вот есть хорошая статья.
В итоге решил сам основывась на решении которое было по сслыке Пришлось еше создать кастомную вью которая основывается на TextInputLayout, повесил слушателя на изменение фокуса и все заработало. Код ниже:
class ButtonCustomLayout @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null) : TextInputLayout(context, attrs) {
override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams) {
super.addView(child, index, params)
child.setOnFocusChangeListener { v, hasFocus ->
if(hasFocus){
editText?.setBackgroundResource(R.drawable.text_input_white_background_focused)
}
else editText?.setBackgroundResource(R.drawable.text_input_white_background_normal)
}
(child as? EditText)?.doAfterTextChanged {
if (isCounterEnabled) {
if (it != null && it.length > counterMaxLength) {
editText?.setBackgroundResource(R.drawable.text_input_white_background_error)
} else {
editText?.setBackgroundResource(R.drawable.text_input_white_background_normal)
}
}
}
}
}
