Closed githeyj closed 4 years ago
same problem on lg g4 running android 6
solved it using : materialSpinnerProvince.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener() { @Override public void onItemSelected(MaterialSpinner materialSpinner, View view, int i, long l) { materialSpinner.clearFocus(); }
@Override
public void onNothingSelected(MaterialSpinner materialSpinner) {
}
});
@dehghanimehrdad materialSpinner.clearFocus(); did not solve the issue.
Hi @dehghanimehrdad and @githeyj please take a look here and let me know if it helped.
@tiper , I tried the solution but it did not work. Please note that when you have one or two spinners, it works fine; but when the spinners are several especially on a scroll view, some spinners misbehave by not closing items......thats my experience on low-end devices
@githeyj Can you provide a sample using the latest version of this component so I can debug the issue?
@tiper below is the sample code...
<com.tiper.MaterialSpinner android:id="@+id/spinner_gender" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="7dp" android:descendantFocusability="beforeDescendants" android:focusable="true" android:focusableInTouchMode="true" android:hint="Select Gender" android:windowSoftInputMode="stateAlwaysHidden" app:spinnerMode="bottomsheet" />
<com.tiper.MaterialSpinner
android:id="@+id/spinner_nannytype"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="7dp"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Select Nanny Type"
android:singleLine="true"
app:spinnerMode="bottomsheet" />
<com.tiper.MaterialSpinner
android:id="@+id/spinner_paytype"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="7dp"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Select Pay Type"
android:singleLine="true"
android:windowSoftInputMode="stateAlwaysHidden"
app:spinnerMode="bottomsheet" />
<com.tiper.MaterialSpinner
android:id="@+id/spinner_payrange"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="7dp"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Select Pay Range"
android:singleLine="true"
android:windowSoftInputMode="stateAlwaysHidden"
app:spinnerMode="bottomsheet" />
<com.tiper.MaterialSpinner
android:id="@+id/spinner_endorsement"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="7dp"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Select Endorsement"
android:singleLine="true"
android:windowSoftInputMode="stateAlwaysHidden"
app:spinnerMode="bottomsheet" />
<com.tiper.MaterialSpinner
android:id="@+id/spinner_skill"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="7dp"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Select Experience"
android:singleLine="true"
android:windowSoftInputMode="stateAlwaysHidden"
app:spinnerMode="bottomsheet" />
<com.tiper.MaterialSpinner
android:id="@+id/spinner_levelOfEducation"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="7dp"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Select Level of Education"
android:singleLine="true"
android:windowSoftInputMode="stateAlwaysHidden"
app:spinnerMode="bottomsheet" />
<com.tiper.MaterialSpinner
android:id="@+id/spinner_religion"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="7dp"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Select Your Religion"
android:singleLine="true"
android:windowSoftInputMode="stateAlwaysHidden"
app:spinnerMode="bottomsheet" />
The Spinners are aligned as below
Hi @tiper did you find anything?
Hi @githeyj you need to add android:descendantFocusability="beforeDescendants"
, android:focusable="true"
and android:focusableInTouchMode="true"
to the parent of the spinner, not on the spinner itself.
Example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<com.tiper.MaterialSpinner
android:id="@+id/spinner_levelOfEducation"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="7dp"
android:hint="Select Level of Education"
android:singleLine="true"
android:windowSoftInputMode="stateAlwaysHidden"
app:spinnerMode="bottomsheet" />
<com.tiper.MaterialSpinner
android:id="@+id/spinner_religion"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="7dp"
android:hint="Select Your Religion"
android:singleLine="true"
android:windowSoftInputMode="stateAlwaysHidden"
app:spinnerMode="bottomsheet" />
</LinearLayout>
Can you please try that and give me back feedback?
same issue
Hi @githeyj you need to add
android:descendantFocusability="beforeDescendants"
,android:focusable="true"
andandroid:focusableInTouchMode="true"
to the parent of the spinner, not on the spinner itself.Example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:descendantFocusability="beforeDescendants" android:focusable="true" android:focusableInTouchMode="true" android:orientation="vertical"> <com.tiper.MaterialSpinner android:id="@+id/spinner_levelOfEducation" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="7dp" android:hint="Select Level of Education" android:singleLine="true" android:windowSoftInputMode="stateAlwaysHidden" app:spinnerMode="bottomsheet" /> <com.tiper.MaterialSpinner android:id="@+id/spinner_religion" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="7dp" android:hint="Select Your Religion" android:singleLine="true" android:windowSoftInputMode="stateAlwaysHidden" app:spinnerMode="bottomsheet" /> </LinearLayout>
Can you please try that and give me back feedback?
It didn't work, when I put it in the immediate parent of the spinner. But works after putting android:focusable="true"
, android:descendantFocusability="beforeDescendants"
, android:focusableInTouchMode="true"
in the root parent as mentioned.
Thanks @tiper
Hi @manivannan23111996 glad to read it.
I will try to update the readme file about this since it seems to be a general question.
@githeyj any update on your side?
@tiper it worked after adding
android:focusable="true",
android:descendantFocusability="beforeDescendants",
android:focusableInTouchMode="true"
on the root parent. Many thanks @tiper .
I have noticed that the spinner items does not close on some devices even after successfully selecting the item of choice