im having a problem with margin in my TextInputLayout. Below picture of problem. It gets very ugly especially when there is 1 element in list.
Posting my code and style below. Tried getting rid of this padding programmaticaly but maybe thats some issue with style itself.
<style name="AppTheme.TextInput.Dropdown" parent="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu">
<item name="materialThemeOverlay">
@style/ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox.Dense
</item>
<item name="boxBackgroundColor">@color/colorBackground</item>
<item name="boxBackgroundMode">filled</item>
</style>
And this is how i make it in code. "view" is the container for elements
private fun addDictionaryField(layoutParams: ConstraintLayout.LayoutParams, formField: FormField): View {
val view = TextInputLayout(ContextThemeWrapper(this, R.style.AppTheme_TextInput_Dropdown))
view.layoutParams = layoutParams
val autoCompleteTextView = AutoCompleteTextView(ContextThemeWrapper(view.context, R.style.AppTheme_AutoCompleteEditText))
autoCompleteTextView.minEms = 4
autoCompleteTextView.maxEms = 6
autoCompleteTextView.isSingleLine = true
autoCompleteTextView.hint = formField.name
autoCompleteTextView.textSize = formField.fontSize?.toFloat() ?: 16F
autoCompleteTextView.dropDownHorizontalOffset = 0
autoCompleteTextView.dropDownWidth = LinearLayout.LayoutParams.MATCH_PARENT
//if (formField.fontColor != "auto" ) autoCompleteTextView.setTextColor(Color.parseColor(formField.fontColor))
//if (formField.backgroundColor != "auto" ) autoCompleteTextView.setBackgroundColor(Color.parseColor(formField.backgroundColor))
autoCompleteTextView.isEnabled = false
val structure = fillFormViewModel.getDictionaryStructure(formField.dictionaryStructure)
if (structure != null) {
if (structure.parentId == null) {
autoCompleteTextView.setAdapter(loadDictionaryFields(structure, null, null))
autoCompleteTextView.setOnItemClickListener { parent, _, position, _ ->
fillFormViewModel.dictionarySelectedElements[formField.id!!] = (parent.adapter.getItem(position) as DictionaryField).id!!
loadChildStructureFields(formField.dictionaryGroup, parent.adapter.getItem(position) as DictionaryField, null, null)
}
}
}
view.addView(autoCompleteTextView)
return view
}
This is how i like it to look (except for this is not dropdown choice menu)
Anyone had simmilar problem by any chance ? :)
Had to change padding in style becouse it had some padding by default
< item name= "android:padding">0dp< /item >
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.