You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: When using an adapter to provide more complex content to an exposed drop down menu, the width of the TextInputLayout is expanded to the width of the menu, not the width of the longest content that will be shown in TextInputLayout.
This is probably easier to explain with screenshots.
This is the screenshot of an exposed drop down menu with three items, "Show", "Warn", and "Hide", set using setOptions().
This is what I expect.
However, I want to show the user additional information about each choice. The labels are deliberately short because there isn't much screen real estate available. So I have a trivial adapter that uses a two-line view, like this:
data classFilterDescription(valtitle:String, valdescr:String) {
overridefuntoString() = title
}
val adapter =object:ArrayAdapter<FilterDescription>(
requireContext(),
android.R.layout.simple_list_item_2,
android.R.id.text1,
) {
val items =listOf( /* FilterDescription objects here */ )
init {
addAll(items)
}
overridefungetView(position:Int, convertView:View?, parent:ViewGroup): View {
val view =super.getView(position, convertView, parent)
val text1 = view.findViewById<TextView>(android.R.id.text1)
val text2 = view.findViewById<TextView>(android.R.id.text2)
getItem(position)?.let { item ->
text1.text = item.title
text2.text = item.descr
}
return view
}
}
If I set this adapter the menu displays two lines per item as expected. However, the width of the TextInputLayout is now the width of the longest descr. Like this with the menu open:
and this with the menu closed:
Expected behavior: The layout should be the maximum width of the content that will be shown in it, not the maximum width of the pop up menu.
Source code: As above.
Android API version: 31
Material Library version: 1.12.0
Device: Emulator
The text was updated successfully, but these errors were encountered:
Description: When using an adapter to provide more complex content to an exposed drop down menu, the width of the
TextInputLayout
is expanded to the width of the menu, not the width of the longest content that will be shown inTextInputLayout
.This is probably easier to explain with screenshots.
This is the screenshot of an exposed drop down menu with three items, "Show", "Warn", and "Hide", set using
setOptions()
.This is what I expect.
However, I want to show the user additional information about each choice. The labels are deliberately short because there isn't much screen real estate available. So I have a trivial adapter that uses a two-line view, like this:
If I set this adapter the menu displays two lines per item as expected. However, the width of the
TextInputLayout
is now the width of the longestdescr
. Like this with the menu open:and this with the menu closed:
Expected behavior: The layout should be the maximum width of the content that will be shown in it, not the maximum width of the pop up menu.
Source code: As above.
Android API version: 31
Material Library version: 1.12.0
Device: Emulator
The text was updated successfully, but these errors were encountered: