I have a spinner defined in a GridLayout like this -
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_column="0"
android:layout_row="0"
android:columnCount="2"
android:rowCount="4"
android:background="@color/colorPrimary"
android:id="@+id/gl">
<android.support.v7.widget.AppCompatTextView
android:layout_column="0"
android:layout_row="1"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:text="Language"
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/lang_spinner"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_column="1"
android:layout_row="1"
android:layout_columnWeight="3"
android:layout_rowWeight="1"/>
</GridLayout>
And the adapter code is -
ArrayList<String> langList = new ArrayList<>();
for (String loc : readerVm.getAvailableLanguages())
{
if (!langList.contains(loc))
{
langList.add(loc);
}
}
Collections.sort(langList);
ArrayAdapter<String> langSpinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, langList);
langSpinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
langSpinner.setAdapter(langSpinnerArrayAdapter);
When the text in the lang_spinner
is small enough to be displayed entirely on the screen it's good enough, but when the text gets larger and goes beyond the screen I was expecting it to get truncated but somehow the lang_spinner
vanishes and all the items in Column 1. First I thought maybe this is because of the GridLayout but I also tried with putting the spinner in linear layout and that being the top most layout of the activity and still the spinner vanished on longer texts.
I also tried using custom spinner layout but with same result. At this point I have no clue of what's going wrong.