Я хочу настроить MultiAutoCompleteTextView
, который будет помещен внутри TextInputLayout
, чтобы использовать Материал, ради возможности повторного использования и обновления базового кода.
Мне еще предстоит начать и у меня уже есть проблемы с этим.
Graphi c демонстрация проблемы
Как видите, первое TextInputLayout
совершенно неверно. У них обоих одинаковая структура и атрибуты, единственное отличие - это настраиваемый вид. По сути, это пустой класс, который расширяет MultiAutoCompleteTextView
.
Ниже приведен xml и пользовательский класс представления.
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/custom_view"
style="@style/Theme.CustomViews.MorphInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/standard_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed">
<com.scitalys.customViews.ui.main.MorphInputText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/standard_view"
style="@style/Theme.CustomViews.MorphInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/custom_view">
<MultiAutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint" />
</com.google.android.material.textfield.TextInputLayout>
class MorphInputText @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : androidx.appcompat.widget.AppCompatMultiAutoCompleteTextView(context, attrs, defStyleAttr) {
init {
this.threshold = 1
val textWatcher = MorphInputTextWatcher
this.addTextChangedListener(textWatcher)
}
}